author: Hui Tang <tanghui20@huawei.com> 2021-05-22 10:44:29 +0800
committer: Herbert Xu <herbert@gondor.apana.org.au> 2021-05-28 15:11:47 +0800
commit: 8fd28fa5046b377039d5bbc0ab2f625dec703980
parent: 6889fc2104e5d20899b91e61daf07a7524b2010d
Commit Summary:
Diffstat:
1 file changed, 8 insertions, 1 deletion
diff --git a/crypto/ecdh.c b/crypto/ecdh.c
index 197467509323..b6f493e82812 100644
--- a/crypto/ecdh.c
+++ b/crypto/ecdh.c
@@ -183,7 +183,16 @@ static int ecdh_init(void)
ret = crypto_register_kpp(&ecdh_nist_p192);
ecdh_nist_p192_registered = ret == 0;
- return crypto_register_kpp(&ecdh_nist_p256);
+ ret = crypto_register_kpp(&ecdh_nist_p256);
+ if (ret)
+ goto nist_p256_error;
+
+ return 0;
+
+nist_p256_error:
+ if (ecdh_nist_p192_registered)
+ crypto_unregister_kpp(&ecdh_nist_p192);
+ return ret;
}
static void ecdh_exit(void)