Skip to content

Commit

Permalink
X.509: fix error return value on the failed path
Browse files Browse the repository at this point in the history
When memory allocation fails, an appropriate return value
should be set.

Fixes: 2155256 ("X.509: support OSCCA SM2-with-SM3 certificate verification")
Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Tianjia Zhang authored and Herbert Xu committed Oct 8, 2020
1 parent 10a2f0b commit 4f28945
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crypto/asymmetric_keys/public_key_sm2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 4f28945

Please sign in to comment.