Skip to contentSkip to conversation

crypto: qat - fix double free during reset

PATCH In review Giovanni Cabiddu 2 participants 2 messages Oct 9, 2023 – Oct 20, 2023

Subsystems (2)
lore
Share & tools
lore

Giovanni Cabiddu

author maintainer
#0 lore raw

PATCH 1/1 crypto: qat - fix double free during reset

From: Svyatoslav Pankratov <[email protected]>

There is no need to free the reset_data structure if the recovery is unsuccessful and the reset is synchronous. The function adf_dev_aer_schedule_reset() handles the cleanup properly. Only asynchronous resets require such structure to be freed inside the reset worker.

Fixes d8cba25d2c68 ("crypto: qat - Intel(R) QAT driver framework")
---
 drivers/crypto/intel/qat/qat_common/adf_aer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/intel/qat/qat_common/adf_aer.c +2 -1
index 04af32a2811c..a39e70bd4b21 100644
@@ -92,7 +92,8 @@ static void adf_device_reset_worker(struct work_struct *work)
 	if (adf_dev_restart(accel_dev)) {
 		/* The device hanged and we can't restart it so stop here */
 		dev_err(&GET_DEV(accel_dev), "Restart device failed\n");
-		kfree(reset_data);
+		if (reset_data->mode == ADF_DEV_RESET_ASYNC)
+			kfree(reset_data);
 		WARN(1, "QAT: device restart failed. Device is unusable\n");
 		return;
 	}
Signature · 1 line
2.41.0
maintainer
#1 lore raw
Quoted 8 lines · Giovanni Cabiddu

From: Svyatoslav Pankratov <[email protected]>

There is no need to free the reset_data structure if the recovery is unsuccessful and the reset is synchronous. The function adf_dev_aer_schedule_reset() handles the cleanup properly. Only asynchronous resets require such structure to be freed inside the reset worker.

Quoted 6 lines
Fixes d8cba25d2c68 ("crypto: qat - Intel(R) QAT driver framework")
---
 drivers/crypto/intel/qat/qat_common/adf_aer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt