* [PATCH] crypto: hisilicon/hpre - fix memory leak in hpre_curve25519_src_init()
@ 2021-12-11 8:17 Weili Qian
2021-12-17 8:39 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Weili Qian @ 2021-12-11 8:17 UTC (permalink / raw)
To: herbert, davem
Cc: linux-kernel, linux-crypto, wangzhou1, liulongfang, Weili Qian
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>
---
drivers/crypto/hisilicon/hpre/hpre_crypto.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
index 0f1724d355b8..97d54c1465c2 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
@@ -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);
}
--
2.33.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] crypto: hisilicon/hpre - fix memory leak in hpre_curve25519_src_init()
2021-12-11 8:17 [PATCH] crypto: hisilicon/hpre - fix memory leak in hpre_curve25519_src_init() Weili Qian
@ 2021-12-17 8:39 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2021-12-17 8:39 UTC (permalink / raw)
To: Weili Qian; +Cc: davem, linux-kernel, linux-crypto, wangzhou1, liulongfang
On Sat, Dec 11, 2021 at 04:17:19PM +0800, Weili Qian wrote:
> 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>
> ---
> drivers/crypto/hisilicon/hpre/hpre_crypto.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-12-17 8:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-11 8:17 [PATCH] crypto: hisilicon/hpre - fix memory leak in hpre_curve25519_src_init() Weili Qian
2021-12-17 8:39 ` Herbert Xu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.