]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
crypto: sm2 - fix a memory leak in sm2
authorHongbo Li <herberthbli@tencent.com>
Fri, 4 Jun 2021 06:30:35 +0000 (14:30 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Jul 2021 14:59:34 +0000 (16:59 +0200)
commitc10cf8d67087d1444757234294d9b920e458b8bc
treee9b7ec8ab2744d86b09a24dcc79fb126387cf638
parent828575bc1b9592556c0d0f49f443f350276a501f
crypto: sm2 - fix a memory leak in sm2

[ Upstream commit 5cd259ca5d466f65ffd21e2e2fa00fb648a8c555 ]

SM2 module alloc ec->Q in sm2_set_pub_key(), when doing alg test in
test_akcipher_one(), it will set public key for every test vector,
and don't free ec->Q. This will cause a memory leak.

This patch alloc ec->Q in sm2_ec_ctx_init().

Fixes: ea7ecb66440b ("crypto: sm2 - introduce OSCCA SM2 asymmetric cipher algorithm")
Signed-off-by: Hongbo Li <herberthbli@tencent.com>
Reviewed-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
crypto/sm2.c