[PATCH] crypto: qat - Don't attempt to register algorithm multiple times

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When multiple devices are present in the system the driver attempts
to register the same algorithm many times.

Signed-off-by: Tadeusz Struk <tadeusz.struk@xxxxxxxxx>
---
 drivers/crypto/qat/qat_common/qat_asym_algs.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c b/drivers/crypto/qat/qat_common/qat_asym_algs.c
index 557a740..3e3c5c8 100644
--- a/drivers/crypto/qat/qat_common/qat_asym_algs.c
+++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c
@@ -58,6 +58,8 @@
 #include "adf_common_drv.h"
 #include "qat_crypto.h"
 
+static atomic_t active_devs;
+
 struct qat_rsa_input_params {
 	union {
 		struct {
@@ -629,11 +631,16 @@ static struct akcipher_alg rsa = {
 
 int qat_asym_algs_register(void)
 {
-	rsa.base.cra_flags = 0;
-	return crypto_register_akcipher(&rsa);
+	if (atomic_add_return(1, &active_devs) == 1) {
+		rsa.base.cra_flags = 0;
+		return crypto_register_akcipher(&rsa);
+	}
+
+	return 0;
 }
 
 void qat_asym_algs_unregister(void)
 {
-	crypto_unregister_akcipher(&rsa);
+	if (atomic_sub_return(1, &active_devs) == 0)
+		crypto_unregister_akcipher(&rsa);
 }

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux