summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2023-09-22 09:15:37 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2023-09-22 09:15:37 -0700
commit2f8d62daf2b5d9835ccd1ae0407de130156c17c1 (patch)
tree9ccf00e61a028f4fa64b96374407363b6c114a1b
parent3a457d2804d4c7e76cb4492c6787fdfb7203fc7d (diff)
parent21155620fbf2edbb071144894ff9d67ba9a1faa0 (diff)
downloadlwn-2f8d62daf2b5d9835ccd1ae0407de130156c17c1.tar.gz
lwn-2f8d62daf2b5d9835ccd1ae0407de130156c17c1.zip
Merge tag 'v6.6-p3' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fix from Herbert Xu: "This fixes a regression in sm2" * tag 'v6.6-p3' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: crypto: sm2 - Fix crash caused by uninitialized context
-rw-r--r--crypto/sm2.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/sm2.c b/crypto/sm2.c
index 285b3cb7c0bc..5ab120d74c59 100644
--- a/crypto/sm2.c
+++ b/crypto/sm2.c
@@ -278,10 +278,14 @@ int sm2_compute_z_digest(struct shash_desc *desc,
if (!ec)
return -ENOMEM;
- err = __sm2_set_pub_key(ec, key, keylen);
+ err = sm2_ec_ctx_init(ec);
if (err)
goto out_free_ec;
+ err = __sm2_set_pub_key(ec, key, keylen);
+ if (err)
+ goto out_deinit_ec;
+
bits_len = SM2_DEFAULT_USERID_LEN * 8;
entl[0] = bits_len >> 8;
entl[1] = bits_len & 0xff;