[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1616150659-10756-3-git-send-email-tanghui20@huawei.com>
Date: Fri, 19 Mar 2021 18:44:19 +0800
From: Hui Tang <tanghui20@...wei.com>
To: <herbert@...dor.apana.org.au>, <davem@...emloft.net>
CC: <linux-crypto@...r.kernel.org>, <xuzaibo@...wei.com>,
<wangzhou1@...ilicon.com>, <linux-kernel@...r.kernel.org>
Subject: [PATCH 2/2] 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@...wei.com>
---
drivers/crypto/hisilicon/hpre/hpre_crypto.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
index 50ccd10..b77473b 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;
}
--
2.8.1
Powered by blists - more mailing lists