Skip to content

Commit

Permalink
crypto: ecdh - fix 'ecdh_init'
Browse files Browse the repository at this point in the history
[ Upstream commit 8fd28fa ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Hui Tang authored and gregkh committed Jul 14, 2021
1 parent 9a091b3 commit cab7a8c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion crypto/ecdh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cab7a8c

Please sign in to comment.