summaryrefslogtreecommitdiff
path: root/drivers/crypto/hisilicon/hpre/hpre_crypto.c
diff options
context:
space:
mode:
authorHui Tang <tanghui20@huawei.com>2021-03-19 13:44:19 +0300
committerHerbert Xu <herbert@gondor.apana.org.au>2021-03-26 12:15:56 +0300
commited48466d3ff94fac09ca5c521a24501eb5908277 (patch)
tree7812f9d8faaef079b9fcf93ad6da428c49791258 /drivers/crypto/hisilicon/hpre/hpre_crypto.c
parentbbe6c4ba518d82974aab3361a445d60c0785d0cc (diff)
downloadlinux-ed48466d3ff94fac09ca5c521a24501eb5908277.tar.xz
crypto: hisilicon/hpre - optimise 'hpre_algs_register' error path
There is redundant code especially when registing new algorithms in the future. Signed-off-by: Hui Tang <tanghui20@huawei.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/hisilicon/hpre/hpre_crypto.c')
-rw-r--r--drivers/crypto/hisilicon/hpre/hpre_crypto.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
index 50ccd1034aae..b77473be5131 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
@@ -1993,25 +1993,24 @@ int hpre_algs_register(struct hisi_qm *qm)
return ret;
ret = crypto_register_kpp(&dh);
- if (ret) {
- crypto_unregister_akcipher(&rsa);
- return ret;
- }
+ if (ret)
+ goto unreg_rsa;
if (qm->ver >= QM_HW_V3) {
ret = hpre_register_ecdh();
if (ret)
- goto reg_err;
+ goto unreg_dh;
ret = crypto_register_kpp(&curve25519_alg);
- if (ret) {
- hpre_unregister_ecdh();
- goto reg_err;
- }
+ if (ret)
+ goto unreg_ecdh;
}
return 0;
-reg_err:
+unreg_ecdh:
+ hpre_unregister_ecdh();
+unreg_dh:
crypto_unregister_kpp(&dh);
+unreg_rsa:
crypto_unregister_akcipher(&rsa);
return ret;
}