diff options
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 | d7b2fdb5a29b7da9f093527717406fac52ac4e49 (patch) | |
tree | 92c61410480759209ab011cc353085e01bb82931 /crypto | |
parent | f962e85df3b6cbf5232410721612c09c24c618a8 (diff) | |
download | linux-crypto-d7b2fdb5a29b7da9f093527717406fac52ac4e49.tar.gz linux-crypto-d7b2fdb5a29b7da9f093527717406fac52ac4e49.zip |
crypto: ecdh - fix 'ecdh_init'
NIST P192 is not unregistered if failed to register NIST P256,
actually it need to unregister the algorithms already registered.
Signed-off-by: Hui Tang <tanghui20@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/ecdh.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/crypto/ecdh.c b/crypto/ecdh.c index 19746750..b6f493e8 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) |