diff options
author | Horia Geanta <horia.geanta@freescale.com> | 2014-04-18 06:01:41 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2014-04-28 06:21:16 -0400 |
commit | 3d67be2761dc4b5b792037f296f3394a29581efc (patch) | |
tree | 6ac408e5c5cf51711740af0cafb7fd1b8e1169b1 /drivers/crypto | |
parent | f51f593b3eb194d01d8980316e6bb1f7d72f567a (diff) |
crypto: caam - fix mem leak in ahash_setkey
In case hash key is bigger than algorithm block size, it is hashed.
In this case, memory is allocated to keep this hash in hashed_key.
hashed_key has to be freed on the key_dma dma mapping error path.
Signed-off-by: Horia Geanta <horia.geanta@freescale.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r-- | drivers/crypto/caam/caamhash.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c index 0378328f47a7..2d244e629ed2 100644 --- a/drivers/crypto/caam/caamhash.c +++ b/drivers/crypto/caam/caamhash.c | |||
@@ -545,7 +545,8 @@ static int ahash_setkey(struct crypto_ahash *ahash, | |||
545 | DMA_TO_DEVICE); | 545 | DMA_TO_DEVICE); |
546 | if (dma_mapping_error(jrdev, ctx->key_dma)) { | 546 | if (dma_mapping_error(jrdev, ctx->key_dma)) { |
547 | dev_err(jrdev, "unable to map key i/o memory\n"); | 547 | dev_err(jrdev, "unable to map key i/o memory\n"); |
548 | return -ENOMEM; | 548 | ret = -ENOMEM; |
549 | goto map_err; | ||
549 | } | 550 | } |
550 | #ifdef DEBUG | 551 | #ifdef DEBUG |
551 | print_hex_dump(KERN_ERR, "ctx.key@"__stringify(__LINE__)": ", | 552 | print_hex_dump(KERN_ERR, "ctx.key@"__stringify(__LINE__)": ", |
@@ -559,6 +560,7 @@ static int ahash_setkey(struct crypto_ahash *ahash, | |||
559 | DMA_TO_DEVICE); | 560 | DMA_TO_DEVICE); |
560 | } | 561 | } |
561 | 562 | ||
563 | map_err: | ||
562 | kfree(hashed_key); | 564 | kfree(hashed_key); |
563 | return ret; | 565 | return ret; |
564 | badkey: | 566 | badkey: |