crypto: dh - fix memory leak
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Tue, 10 Jul 2018 14:22:52 +0000 (09:22 -0500)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 20 Jul 2018 05:51:21 +0000 (13:51 +0800)
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>
Reviewed-by: Stephan Müller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/dh.c

index 8f79269db2b7c67e25a657bdf2e76fb690185e09..09a44de4209d1632b9478917c45a03049c667cbb 100644 (file)
@@ -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;
        }