diff mbox series

X.509: fix error return value on the failed path

Message ID 20201005144628.83875-1-tianjia.zhang@linux.alibaba.com (mailing list archive)
State New
Headers show
Series X.509: fix error return value on the failed path | expand

Commit Message

tianjia.zhang Oct. 5, 2020, 2:46 p.m. UTC
When memory allocation fails, an appropriate return value
should be set.

Fixes: 215525639631 ("X.509: support OSCCA SM2-with-SM3 certificate verification")
Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
---
 crypto/asymmetric_keys/public_key_sm2.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Herbert Xu Oct. 8, 2020, 5:43 a.m. UTC | #1
On Mon, Oct 05, 2020 at 10:46:28PM +0800, Tianjia Zhang wrote:
> When memory allocation fails, an appropriate return value
> should be set.
> 
> Fixes: 215525639631 ("X.509: support OSCCA SM2-with-SM3 certificate verification")
> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> ---
>  crypto/asymmetric_keys/public_key_sm2.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Patch applied.  Thanks.
diff mbox series

Patch

diff --git a/crypto/asymmetric_keys/public_key_sm2.c b/crypto/asymmetric_keys/public_key_sm2.c
index 7325cf21dbb4..66b614e1eccd 100644
--- a/crypto/asymmetric_keys/public_key_sm2.c
+++ b/crypto/asymmetric_keys/public_key_sm2.c
@@ -36,8 +36,10 @@  int cert_sig_digest_update(const struct public_key_signature *sig,
 
 	desc_size = crypto_shash_descsize(tfm) + sizeof(*desc);
 	desc = kzalloc(desc_size, GFP_KERNEL);
-	if (!desc)
+	if (!desc) {
+		ret = -ENOMEM;
 		goto error_free_tfm;
+	}
 
 	desc->tfm = tfm;