crypto: hisilicon/hpre - fix memory leak in hpre_curve25519_src_init()
authorWeili Qian <qianweili@huawei.com>
Sat, 11 Dec 2021 08:17:19 +0000 (16:17 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 17 Dec 2021 05:59:48 +0000 (16:59 +1100)
hpre_curve25519_src_init() allocates memory for 'ptr' before calling
memcmp(). If memcmp() returns 0, the function will return '-EINVAL'
without freeing memory.

Signed-off-by: Weili Qian <qianweili@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/hisilicon/hpre/hpre_crypto.c

index 0f1724d355b810fdaf36210de36f0c7b19d1b398..97d54c1465c2b05c629133b76117ec6a1594521c 100644 (file)
@@ -1862,7 +1862,7 @@ static int hpre_curve25519_src_init(struct hpre_asym_request *hpre_req,
         */
        if (memcmp(ptr, p, ctx->key_sz) == 0) {
                dev_err(dev, "gx is p!\n");
-               return -EINVAL;
+               goto err;
        } else if (memcmp(ptr, p, ctx->key_sz) > 0) {
                hpre_curve25519_src_modulo_p(ptr);
        }