1 From d574b707c873d6ef1a2a155f8cfcfecd821e9a2e Mon Sep 17 00:00:00 2001
2 From: Gilad Ben-Yossef <gilad@benyossef.com>
3 Date: Thu, 18 Apr 2019 16:38:50 +0300
4 Subject: crypto: ccree - fix mem leak on error path
6 From: Gilad Ben-Yossef <gilad@benyossef.com>
8 commit d574b707c873d6ef1a2a155f8cfcfecd821e9a2e upstream.
10 Fix a memory leak on the error path of IV generation code.
12 Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
13 Cc: stable@vger.kernel.org # v4.19+
14 Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
15 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18 drivers/crypto/ccree/cc_ivgen.c | 9 +++------
19 1 file changed, 3 insertions(+), 6 deletions(-)
21 --- a/drivers/crypto/ccree/cc_ivgen.c
22 +++ b/drivers/crypto/ccree/cc_ivgen.c
23 @@ -154,9 +154,6 @@ void cc_ivgen_fini(struct cc_drvdata *dr
26 ivgen_ctx->pool = NULL_SRAM_ADDR;
28 - /* release "this" context */
33 @@ -174,10 +171,12 @@ int cc_ivgen_init(struct cc_drvdata *drv
36 /* Allocate "this" context */
37 - ivgen_ctx = kzalloc(sizeof(*ivgen_ctx), GFP_KERNEL);
38 + ivgen_ctx = devm_kzalloc(device, sizeof(*ivgen_ctx), GFP_KERNEL);
42 + drvdata->ivgen_handle = ivgen_ctx;
44 /* Allocate pool's header for initial enc. key/IV */
45 ivgen_ctx->pool_meta = dma_alloc_coherent(device, CC_IVPOOL_META_SIZE,
46 &ivgen_ctx->pool_meta_dma,
47 @@ -196,8 +195,6 @@ int cc_ivgen_init(struct cc_drvdata *drv
51 - drvdata->ivgen_handle = ivgen_ctx;
53 return cc_init_iv_sram(drvdata);