]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 14 May 2017 12:08:19 +0000 (14:08 +0200)
commit3e871381811a3fffd4a9befc6c41a5f7c3ce0525
treec3cd99dee75046adc22cafc616900a3d058f24b8
parent93bb6661baf0467dc9db2d2a8ef6cf92131977b6
crypto: caam - fix error path for ctx_dma mapping failure

commit 87ec02e7409d787348c244039aa3536a812dfa8b upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/crypto/caam/caamhash.c