]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/crypto-ccree-fix-mem-leak-on-error-path.patch
Linux 4.14.121
[thirdparty/kernel/stable-queue.git] / queue-4.19 / crypto-ccree-fix-mem-leak-on-error-path.patch
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
5
6 From: Gilad Ben-Yossef <gilad@benyossef.com>
7
8 commit d574b707c873d6ef1a2a155f8cfcfecd821e9a2e upstream.
9
10 Fix a memory leak on the error path of IV generation code.
11
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>
16
17 ---
18 drivers/crypto/ccree/cc_ivgen.c | 9 +++------
19 1 file changed, 3 insertions(+), 6 deletions(-)
20
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
24 }
25
26 ivgen_ctx->pool = NULL_SRAM_ADDR;
27 -
28 - /* release "this" context */
29 - kfree(ivgen_ctx);
30 }
31
32 /*!
33 @@ -174,10 +171,12 @@ int cc_ivgen_init(struct cc_drvdata *drv
34 int rc;
35
36 /* Allocate "this" context */
37 - ivgen_ctx = kzalloc(sizeof(*ivgen_ctx), GFP_KERNEL);
38 + ivgen_ctx = devm_kzalloc(device, sizeof(*ivgen_ctx), GFP_KERNEL);
39 if (!ivgen_ctx)
40 return -ENOMEM;
41
42 + drvdata->ivgen_handle = ivgen_ctx;
43 +
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
48 goto out;
49 }
50
51 - drvdata->ivgen_handle = ivgen_ctx;
52 -
53 return cc_init_iv_sram(drvdata);
54
55 out: