Patchwork crypto: dh - fix memory leak

login
register
mail settings
Submitter Gustavo A. R. Silva
Date July 10, 2018, 2:22 p.m.
Message ID <20180710142252.GA19600@embeddedor.com>
Download mbox | patch
Permalink /patch/10517103/
State Accepted
Delegated to: Herbert Xu
Headers show

Comments

Gustavo A. R. Silva - July 10, 2018, 2:22 p.m.
In case memory resources for *base* were allocated, release them
before return.

Addresses-Coverity-ID: 1471702 ("Resource leak")
Fixes: e3fe0ae12962 ("crypto: dh - add public key verification test")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 crypto/dh.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Stephan Mueller - July 10, 2018, 3:28 p.m.
Am Dienstag, 10. Juli 2018, 16:22:52 CEST schrieb Gustavo A. R. Silva:

Hi Gustavo,

> In case memory resources for *base* were allocated, release them
> before return.

Thanks a lot.

Reviewed-by: Stephan Müller <smueller@chronox.de>

Ciao
Stephan
Gustavo A. R. Silva - July 10, 2018, 4:49 p.m.
Hi Stephan,

On 07/10/2018 10:28 AM, Stephan Müller wrote:
> Am Dienstag, 10. Juli 2018, 16:22:52 CEST schrieb Gustavo A. R. Silva:
> 
> Hi Gustavo,
> 
>> In case memory resources for *base* were allocated, release them
>> before return.
> 
> Thanks a lot.
> 

Glad to help. :)

> Reviewed-by: Stephan Müller <smueller@chronox.de>
> 

Thanks
--
Gustavo
Herbert Xu - July 20, 2018, 5:53 a.m.
On Tue, Jul 10, 2018 at 09:22:52AM -0500, Gustavo A. R. Silva wrote:
> In case memory resources for *base* were allocated, release them
> before return.
> 
> Addresses-Coverity-ID: 1471702 ("Resource leak")
> Fixes: e3fe0ae12962 ("crypto: dh - add public key verification test")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Patch applied.  Thanks.

Patch

diff --git a/crypto/dh.c b/crypto/dh.c
index 8f79269..09a44de 100644
--- a/crypto/dh.c
+++ b/crypto/dh.c
@@ -174,7 +174,7 @@  static int dh_compute_value(struct kpp_request *req)
 		}
 		ret = dh_is_pubkey_valid(ctx, base);
 		if (ret)
-			goto err_free_val;
+			goto err_free_base;
 	} else {
 		base = ctx->g;
 	}