提交 51fa916b 编写于 作者: W Weili Qian 提交者: Herbert Xu

crypto: hisilicon/hpre - fix memory leak in hpre_curve25519_src_init()

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: NWeili Qian <qianweili@huawei.com>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
上级 244d22ff
...@@ -1862,7 +1862,7 @@ static int hpre_curve25519_src_init(struct hpre_asym_request *hpre_req, ...@@ -1862,7 +1862,7 @@ static int hpre_curve25519_src_init(struct hpre_asym_request *hpre_req,
*/ */
if (memcmp(ptr, p, ctx->key_sz) == 0) { if (memcmp(ptr, p, ctx->key_sz) == 0) {
dev_err(dev, "gx is p!\n"); dev_err(dev, "gx is p!\n");
return -EINVAL; goto err;
} else if (memcmp(ptr, p, ctx->key_sz) > 0) { } else if (memcmp(ptr, p, ctx->key_sz) > 0) {
hpre_curve25519_src_modulo_p(ptr); hpre_curve25519_src_modulo_p(ptr);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册