summaryrefslogtreecommitdiff
path: root/drivers/crypto
diff options
context:
space:
mode:
authorCristian Stoica <cristian.stoica@freescale.com>2014-09-23 10:17:42 (GMT)
committerMatthew Weigel <Matthew.Weigel@freescale.com>2014-12-11 18:41:05 (GMT)
commit2b79116058767a16442d3571505f151fe2df7280 (patch)
tree1ae3d18aa7bd74a514bf967f31c91ec013e8e374 /drivers/crypto
parent8881364ff1250c0c878431ff3a2f4118ecf20118 (diff)
downloadlinux-fsl-qoriq-2b79116058767a16442d3571505f151fe2df7280.tar.xz
crypto: caamhash: fix jr alloc leak on error path
Memory allocated for ctx->jrdev is freed in all error paths except when ahash_set_sh_desc(ahash) fails. Add a check for this case and free memory as appropriate. Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Change-Id: I1c4e45a8cfdc6d24d768e90a148bb398b3d09f52 Reviewed-on: http://git.am.freescale.net:8181/19803 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Reviewed-by: Mircea Pop <mircea.pop@freescale.com> Reviewed-by: Matthew Weigel <Matthew.Weigel@freescale.com>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/caam/caamhash.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
index c8f1558..f23186e 100644
--- a/drivers/crypto/caam/caamhash.c
+++ b/drivers/crypto/caam/caamhash.c
@@ -1772,7 +1772,7 @@ static int caam_hash_cra_init(struct crypto_tfm *tfm)
HASH_MSG_LEN + SHA256_DIGEST_SIZE,
HASH_MSG_LEN + 64,
HASH_MSG_LEN + SHA512_DIGEST_SIZE };
- int ret = 0;
+ int ret;
u8 op_id;
/*
@@ -1801,7 +1801,8 @@ static int caam_hash_cra_init(struct crypto_tfm *tfm)
sizeof(struct caam_hash_state));
ret = ahash_set_sh_desc(ahash);
- return ret;
+ if (ret == 0)
+ return ret;
out_err:
caam_jr_free(ctx->jrdev);