Re: [PATCH v2] crypto: sm2 - fix a memory leak in sm2

From: Herbert Xu
Date: Fri Jun 11 2021 - 03:23:47 EST


On Fri, Jun 04, 2021 at 02:30:35PM +0800, Hongbo Li wrote:
> From: Hongbo Li <herberthbli@xxxxxxxxxxx>
>
> 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@xxxxxxxxxxx>
> Reviewed-by: Tianjia Zhang <tianjia.zhang@xxxxxxxxxxxxxxxxx>
> ---
> crypto/sm2.c | 24 ++++++++++--------------
> 1 file changed, 10 insertions(+), 14 deletions(-)

Patch applied. Thanks.
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt