OSDN Git Service

crypto: caam - fix error path for ctx_dma mapping failure
authorHoria Geantă <horia.geanta@nxp.com>
Fri, 10 Feb 2017 12:07:23 +0000 (14:07 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 15 Feb 2017 05:23:42 +0000 (13:23 +0800)
commit87ec02e7409d787348c244039aa3536a812dfa8b
tree097f6cd4c4ae13bdcd3e9b98b0a8c5a2b7f3f914
parentbbf2234494afd14a720d61a233c21b95e4261326
crypto: caam - fix error path for ctx_dma mapping failure

In case ctx_dma dma mapping fails, ahash_unmap_ctx() tries to
dma unmap an invalid address:
map_seq_out_ptr_ctx() / ctx_map_to_sec4_sg() -> goto unmap_ctx ->
-> ahash_unmap_ctx() -> dma unmap ctx_dma

There is also possible to reach ahash_unmap_ctx() with ctx_dma
uninitialzed or to try to unmap the same address twice.

Fix these by setting ctx_dma = 0 where needed:
-initialize ctx_dma in ahash_init()
-clear ctx_dma in case of mapping error (instead of holding
the error code returned by the dma map function)
-clear ctx_dma after each unmapping

Fixes: 32686d34f8fb6 ("crypto: caam - ensure that we clean up after an error")
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/caam/caamhash.c