From a5dc00f9415d5974daf738830cf9a01d0d0b1bbe Mon Sep 17 00:00:00 2001 From: makejian Date: Tue, 16 May 2023 10:35:59 +0800 Subject: [PATCH] crypto: fix bug in the asymmetric encryption process (1)uninitialized memory cause release failure (2)wrong release timing Signed-off-by: makejian --- crypto/cryptodev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/crypto/cryptodev.c b/crypto/cryptodev.c index bda06e44d9..fc0e4daa83 100644 --- a/crypto/cryptodev.c +++ b/crypto/cryptodev.c @@ -632,7 +632,7 @@ int cryptodev_key(FAR struct crypt_kop *kop) return -EINVAL; } - krp = kmm_malloc(sizeof *krp); + krp = kmm_zalloc(sizeof *krp); krp->krp_op = kop->crk_op; krp->krp_status = kop->crk_status; krp->krp_iparams = kop->crk_iparams; @@ -665,10 +665,6 @@ int cryptodev_key(FAR struct crypt_kop *kop) } memcpy(krp->krp_param[i].crp_p, kop->crk_param[i].crp_p, size); - if (error) - { - goto fail; - } } error = crypto_kinvoke(krp);