Add check for the return value of alloc_workqueue since it may return
NULL pointer.
Moreover, add destroy_workqueue when rtw89_load_firmware fails.
Fixes: e3ec7017f6a2 ("rtw89: add Realtek 802.11ax driver")
Signed-off-by: Jiasheng Jiang <[email protected]>
---
CHangelog:
v1 -> v2:
1. Add destroy_workqueue when rtw89_load_firmware fails.
---
drivers/net/wireless/realtek/rtw89/core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index 931aff8b5dc9..e99eccf11c76 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -3124,6 +3124,8 @@ int rtw89_core_init(struct rtw89_dev *rtwdev)
INIT_DELAYED_WORK(&rtwdev->cfo_track_work, rtw89_phy_cfo_track_work);
INIT_DELAYED_WORK(&rtwdev->forbid_ba_work, rtw89_forbid_ba_work);
rtwdev->txq_wq = alloc_workqueue("rtw89_tx_wq", WQ_UNBOUND | WQ_HIGHPRI, 0);
+ if (!rtwdev->txq_wq)
+ return -ENOMEM;
spin_lock_init(&rtwdev->ba_lock);
spin_lock_init(&rtwdev->rpwm_lock);
mutex_init(&rtwdev->mutex);
@@ -3149,6 +3151,7 @@ int rtw89_core_init(struct rtw89_dev *rtwdev)
ret = rtw89_load_firmware(rtwdev);
if (ret) {
rtw89_warn(rtwdev, "no firmware loaded\n");
+ destroy_workqueue(rtwdev->txq_wq);
return ret;
}
rtw89_ser_init(rtwdev);
--
2.25.1
> -----Original Message-----
> From: Jiasheng Jiang <[email protected]>
> Sent: Wednesday, January 4, 2023 10:29 PM
> To: [email protected]
> Cc: Ping-Ke Shih <[email protected]>; [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected]; [email protected];
> [email protected]; Jiasheng Jiang <[email protected]>
> Subject: [PATCH v2] wifi: rtw89: Add missing check for alloc_workqueue
>
> Add check for the return value of alloc_workqueue since it may return
> NULL pointer.
> Moreover, add destroy_workqueue when rtw89_load_firmware fails.
>
> Fixes: e3ec7017f6a2 ("rtw89: add Realtek 802.11ax driver")
> Signed-off-by: Jiasheng Jiang <[email protected]>
Acked-by: Ping-Ke Shih <[email protected]>
> ---
> CHangelog:
>
> v1 -> v2:
>
> 1. Add destroy_workqueue when rtw89_load_firmware fails.
> ---
> drivers/net/wireless/realtek/rtw89/core.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
> index 931aff8b5dc9..e99eccf11c76 100644
> --- a/drivers/net/wireless/realtek/rtw89/core.c
> +++ b/drivers/net/wireless/realtek/rtw89/core.c
> @@ -3124,6 +3124,8 @@ int rtw89_core_init(struct rtw89_dev *rtwdev)
> INIT_DELAYED_WORK(&rtwdev->cfo_track_work, rtw89_phy_cfo_track_work);
> INIT_DELAYED_WORK(&rtwdev->forbid_ba_work, rtw89_forbid_ba_work);
> rtwdev->txq_wq = alloc_workqueue("rtw89_tx_wq", WQ_UNBOUND | WQ_HIGHPRI, 0);
> + if (!rtwdev->txq_wq)
> + return -ENOMEM;
> spin_lock_init(&rtwdev->ba_lock);
> spin_lock_init(&rtwdev->rpwm_lock);
> mutex_init(&rtwdev->mutex);
> @@ -3149,6 +3151,7 @@ int rtw89_core_init(struct rtw89_dev *rtwdev)
> ret = rtw89_load_firmware(rtwdev);
> if (ret) {
> rtw89_warn(rtwdev, "no firmware loaded\n");
> + destroy_workqueue(rtwdev->txq_wq);
> return ret;
> }
> rtw89_ser_init(rtwdev);
> --
> 2.25.1
On Wed, Jan 04, 2023 at 10:29:01PM +0800, Jiasheng Jiang wrote:
> Add check for the return value of alloc_workqueue since it may return
> NULL pointer.
> Moreover, add destroy_workqueue when rtw89_load_firmware fails.
>
> Fixes: e3ec7017f6a2 ("rtw89: add Realtek 802.11ax driver")
> Signed-off-by: Jiasheng Jiang <[email protected]>
> ---
> CHangelog:
>
> v1 -> v2:
>
> 1. Add destroy_workqueue when rtw89_load_firmware fails.
> ---
> drivers/net/wireless/realtek/rtw89/core.c | 3 +++
> 1 file changed, 3 insertions(+)
>
Thanks,
Reviewed-by: Leon Romanovsky <[email protected]>
Jiasheng Jiang <[email protected]> wrote:
> Add check for the return value of alloc_workqueue since it may return
> NULL pointer.
> Moreover, add destroy_workqueue when rtw89_load_firmware fails.
>
> Fixes: e3ec7017f6a2 ("rtw89: add Realtek 802.11ax driver")
> Signed-off-by: Jiasheng Jiang <[email protected]>
> Acked-by: Ping-Ke Shih <[email protected]>
> Reviewed-by: Leon Romanovsky <[email protected]>
Patch applied to wireless-next.git, thanks.
ed9e6166eb09 wifi: rtw89: Add missing check for alloc_workqueue
--
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches