Patch "crypto: qat - fix unregistration of crypto algorithms" has been added to the 6.1-stable tree

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

 



This is a note to let you know that I've just added the patch titled

    crypto: qat - fix unregistration of crypto algorithms

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     crypto-qat-fix-unregistration-of-crypto-algorithms.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 5c25b427951e0ee11806cb8d7865548de524084f
Author: Giovanni Cabiddu <giovanni.cabiddu@xxxxxxxxx>
Date:   Thu Sep 14 10:55:48 2023 +0100

    crypto: qat - fix unregistration of crypto algorithms
    
    [ Upstream commit 9b2f33a1bfcda90b857431a764c9c8f9a412bbe5 ]
    
    The function adf_dev_init(), through the subsystem qat_crypto, populates
    the list of list of crypto instances accel_dev->crypto_list.
    If the list of instances is not empty, the function adf_dev_start() will
    then call qat_algs_registers() and qat_asym_algs_register() to register
    the crypto algorithms into the crypto framework.
    
    If any of the functions in adf_dev_start() fail, the caller of such
    function, in the error path calls adf_dev_down() which in turn call
    adf_dev_stop() and adf_dev_shutdown(), see for example the function
    state_store in adf_sriov.c.
    However, if the registration of crypto algorithms is not done,
    adf_dev_stop() will try to unregister the algorithms regardless.
    This might cause the counter active_devs in qat_algs.c and
    qat_asym_algs.c to get to a negative value.
    
    Add a new state, ADF_STATUS_CRYPTO_ALGS_REGISTERED, which tracks if the
    crypto algorithms are registered into the crypto framework. Then use
    this to unregister the algorithms if such flag is set. This ensures that
    the crypto algorithms are only unregistered if previously registered.
    
    Fixes: d8cba25d2c68 ("crypto: qat - Intel(R) QAT driver framework")
    Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@xxxxxxxxx>
    Reviewed-by: Adam Guerin <adam.guerin@xxxxxxxxx>
    Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/crypto/qat/qat_common/adf_common_drv.h b/drivers/crypto/qat/qat_common/adf_common_drv.h
index bff613eec5c4b..d2bc2361cd069 100644
--- a/drivers/crypto/qat/qat_common/adf_common_drv.h
+++ b/drivers/crypto/qat/qat_common/adf_common_drv.h
@@ -25,6 +25,7 @@
 #define ADF_STATUS_AE_STARTED 6
 #define ADF_STATUS_PF_RUNNING 7
 #define ADF_STATUS_IRQ_ALLOCATED 8
+#define ADF_STATUS_CRYPTO_ALGS_REGISTERED 9
 
 enum adf_dev_reset_mode {
 	ADF_DEV_RESET_ASYNC = 0,
diff --git a/drivers/crypto/qat/qat_common/adf_init.c b/drivers/crypto/qat/qat_common/adf_init.c
index d6f3314246179..2e3481270c4ba 100644
--- a/drivers/crypto/qat/qat_common/adf_init.c
+++ b/drivers/crypto/qat/qat_common/adf_init.c
@@ -209,6 +209,8 @@ int adf_dev_start(struct adf_accel_dev *accel_dev)
 		clear_bit(ADF_STATUS_STARTED, &accel_dev->status);
 		return -EFAULT;
 	}
+	set_bit(ADF_STATUS_CRYPTO_ALGS_REGISTERED, &accel_dev->status);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(adf_dev_start);
@@ -237,10 +239,12 @@ void adf_dev_stop(struct adf_accel_dev *accel_dev)
 	clear_bit(ADF_STATUS_STARTING, &accel_dev->status);
 	clear_bit(ADF_STATUS_STARTED, &accel_dev->status);
 
-	if (!list_empty(&accel_dev->crypto_list)) {
+	if (!list_empty(&accel_dev->crypto_list) &&
+	    test_bit(ADF_STATUS_CRYPTO_ALGS_REGISTERED, &accel_dev->status)) {
 		qat_algs_unregister();
 		qat_asym_algs_unregister();
 	}
+	clear_bit(ADF_STATUS_CRYPTO_ALGS_REGISTERED, &accel_dev->status);
 
 	list_for_each(list_itr, &service_table) {
 		service = list_entry(list_itr, struct service_hndl, list);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux