crypto: qat - Fix missing destroy_workqueue in adf_init_aer()
Subsystems (2)
PATCH 1/1 crypto: qat - Fix missing destroy_workqueue in adf_init_aer()
The adf_init_aer() won't destroy device_reset_wq when alloc_workqueue() for device_sriov_wq failed. Add destroy_workqueue for device_reset_wq to fix this issue.
--- drivers/crypto/intel/qat/qat_common/adf_aer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/crypto/intel/qat/qat_common/adf_aer.c +3 -1
@@ -281,8 +281,10 @@ int adf_init_aer(void)return -EFAULT ; device_sriov_wq =alloc_workqueue ("qat_device_sriov_wq" ,0 ,0 ); -if (!device_sriov_wq) +if (!device_sriov_wq) { +destroy_workqueue (device_reset_wq);return -EFAULT ; + }return 0 ; }
Signature · 1 line
2.17.1
Cabiddu, Giovanni
maintainerQuoted 15 lines · Wang Hai
The
adf_init_aer()won't destroydevice_reset_wqwhenalloc_workqueue()fordevice_sriov_wqfailed. Adddestroy_workqueuefordevice_reset_wqto fix this issue.Fixes 4469f9b23468 ("crypto: qat - re-enable sriov after pf reset")Signed-off-by Wang Hai <[email protected]>--- drivers/crypto/intel/qat/qat_common/adf_aer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/crypto/intel/qat/qat_common/adf_aer.c +0
-0
drivers/crypto/intel/qat/qat_common/adf_aer.c int adf_init_aer(void) · line 285
Quoted 6 lines
drivers/crypto/intel/qat/qat_common/adf_aer.c +2
-1@@ -281,8 +281,10 @@ int adf_init_aer(void)return -EFAULT ; device_sriov_wq =alloc_workqueue ("qat_device_sriov_wq" ,0 ,0 ); -if (!device_sriov_wq) +if (!device_sriov_wq) { +destroy_workqueue (device_reset_wq);
The missing destroy_workqueue() here is intentional as the device_reset_wq is destroyed in adf_exit_aer() which is called if adf_init_aer() fails, see [1].
With this change, destroy_workqueue() is called twice.
Regards,
Signature · 3 lines
Giovanni [1] https://elixir.bootlin.com/linux/v6.11.5/source/drivers/crypto/intel/qat/qat_common/adf_ctl_drv.c#L425
Quoted 18 lines · Giovanni
Quoted 17 lines · Wang Hai
The
adf_init_aer()won't destroydevice_reset_wqwhenalloc_workqueue()fordevice_sriov_wqfailed. Adddestroy_workqueuefordevice_reset_wqto fix this issue.Fixes 4469f9b23468 ("crypto: qat - re-enable sriov after pf reset")Signed-off-by Wang Hai <[email protected]>--- drivers/crypto/intel/qat/qat_common/adf_aer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/crypto/intel/qat/qat_common/adf_aer.c +0
-0@@ -281,8 +281,10 @@ int adf_init_aer(void)return -EFAULT ;
Quoted 8 lines
drivers/crypto/intel/qat/qat_common/adf_aer.c int adf_init_aer(void) · line 285
Quoted 4 lines
drivers/crypto/intel/qat/qat_common/adf_aer.c +2
-1device_sriov_wq =alloc_workqueue ("qat_device_sriov_wq" ,0 ,0 ); -if (!device_sriov_wq) +if (!device_sriov_wq) { +destroy_workqueue (device_reset_wq);The missing
destroy_workqueue()here is intentional as thedevice_reset_wqis destroyed inadf_exit_aer()which is called ifadf_init_aer()fails, see [1].
Hi, Giovanni.
Thanks for the review.
If adf_init_aer() fails, it will goto err_aer and then call adf_exit_misc_wq() instead of goto err_pf_wq and then call adf_exit_aer(). So this patch is needed.
static long adf_ctl_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) {
...
if (adf_init_aer()) goto err_aer; ... err_pf_wq: adf_exit_aer(); // will not be called when adf_init_aer() failed err_aer: adf_exit_misc_wq();
err_misc_wq:
...
}
Quoted 4 lines
With this change,
destroy_workqueue()is called twice.Regards,
Cabiddu, Giovanni
maintainerQuoted 28 lines · Wang Hai
Quoted 11 lines · Giovanni
Quoted 10 lines · Wang Hai
The
adf_init_aer()won't destroydevice_reset_wqwhenalloc_workqueue()fordevice_sriov_wqfailed. Adddestroy_workqueuefordevice_reset_wqto fix this issue.Fixes 4469f9b23468 ("crypto: qat - re-enable sriov after pf reset")Signed-off-by Wang Hai <[email protected]>--- drivers/crypto/intel/qat/qat_common/adf_aer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)Quoted 14 lines
drivers/crypto/intel/qat/qat_common/adf_aer.c int adf_init_aer(void) · line 284
Quoted 10 lines
drivers/crypto/intel/qat/qat_common/adf_aer.c +2
-1@@ -281,8 +281,10 @@ int adf_init_aer(void)return -EFAULT ; device_sriov_wq =alloc_workqueue ("qat_device_sriov_wq" ,0 ,0 ); -if (!device_sriov_wq) +if (!device_sriov_wq) { +destroy_workqueue (device_reset_wq);The missing
destroy_workqueue()here is intentional as thedevice_reset_wqis destroyed inadf_exit_aer()which is called ifadf_init_aer()fails, see [1].
Quoted 7 lines
Hi, Giovanni.
Thanks for the review.
If
adf_init_aer()fails, it will gotoerr_aerand then calladf_exit_misc_wq()instead of gotoerr_pf_wqand then calladf_exit_aer(). So this patch is needed.
Sorry, I overlooked it. You are right.
On the error path I would also set device_reset_wq to NULL.
if (!device_sriov_wq) {
destroy_workqueue(device_reset_wq);
device_reset_wq = NULL;
return -EFAULT;
}Regards,
Signature · 1 line
Giovanni
Quoted 36 lines · Giovanni
Quoted 28 lines · Wang Hai
Quoted 11 lines · Giovanni
Quoted 10 lines · Wang Hai
The
adf_init_aer()won't destroydevice_reset_wqwhenalloc_workqueue()fordevice_sriov_wqfailed. Adddestroy_workqueuefordevice_reset_wqto fix this issue.Fixes 4469f9b23468 ("crypto: qat - re-enable sriov after pf reset")Signed-off-by Wang Hai <[email protected]>--- drivers/crypto/intel/qat/qat_common/adf_aer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)Quoted 14 lines
drivers/crypto/intel/qat/qat_common/adf_aer.c int adf_init_aer(void) · line 284
Quoted 10 lines
drivers/crypto/intel/qat/qat_common/adf_aer.c +2
-1@@ -281,8 +281,10 @@ int adf_init_aer(void)return -EFAULT ; device_sriov_wq =alloc_workqueue ("qat_device_sriov_wq" ,0 ,0 ); -if (!device_sriov_wq) +if (!device_sriov_wq) { +destroy_workqueue (device_reset_wq);The missing
destroy_workqueue()here is intentional as thedevice_reset_wqis destroyed inadf_exit_aer()which is called ifadf_init_aer()fails, see [1].Quoted 7 lines
Hi, Giovanni.
Thanks for the review.
If
adf_init_aer()fails, it will gotoerr_aerand then calladf_exit_misc_wq()instead of gotoerr_pf_wqand then calladf_exit_aer(). So this patch is needed.
Quoted 8 lines
Sorry, I overlooked it. You are right.
On the error path I would also setdevice_reset_wqto NULL.if (!device_sriov_wq) { destroy_workqueue(device_reset_wq); device_reset_wq = NULL; return -EFAULT; }
Thanks for the suggestion, I will send a v2 patch
Quoted 2 lines
Regards,