]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commit20f6b71f94711e4570a460dcf11470417796586c
tree097f6cd4c4ae13bdcd3e9b98b0a8c5a2b7f3f914
parent11e854b456c3cf8c276420843c5c8917fabf481b
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: c38ad1713e841 ("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