From 2b79116058767a16442d3571505f151fe2df7280 Mon Sep 17 00:00:00 2001 From: Cristian Stoica Date: Tue, 23 Sep 2014 13:17:42 +0300 Subject: 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 Change-Id: I1c4e45a8cfdc6d24d768e90a148bb398b3d09f52 Reviewed-on: http://git.am.freescale.net:8181/19803 Tested-by: Review Code-CDREVIEW Reviewed-by: Horia Ioan Geanta Neag Reviewed-by: Mircea Pop Reviewed-by: Matthew Weigel 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); -- cgit v0.10.2