diff mbox series

[-next] wifi: rtw88: add missing destroy_workqueue() on error path in rtw_core_init()

Message ID 20220825133731.1877569-1-yangyingliang@huawei.com
State Superseded
Headers show
Series [-next] wifi: rtw88: add missing destroy_workqueue() on error path in rtw_core_init() | expand

Commit Message

Yang Yingliang Aug. 25, 2022, 1:37 p.m. UTC
Add the missing destroy_workqueue() before return from rtw_core_init()
in error path.

Fixes: fe101716c7c9 ("rtw88: replace tx tasklet with work queue")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/net/wireless/realtek/rtw88/main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Ping-Ke Shih Aug. 26, 2022, 12:44 a.m. UTC | #1
> -----Original Message-----
> From: Yang Yingliang <yangyingliang@huawei.com>
> Sent: Thursday, August 25, 2022 9:38 PM
> To: linux-kernel@vger.kernel.org; netdev@vger.kernel.org; linux-wireless@vger.kernel.org
> Cc: tony0620emma@gmail.com; kvalo@kernel.org; Bernie Huang <phhuang@realtek.com>
> Subject: [PATCH -next] wifi: rtw88: add missing destroy_workqueue() on error path in rtw_core_init()
> 
> Add the missing destroy_workqueue() before return from rtw_core_init()
> in error path.
> 
> Fixes: fe101716c7c9 ("rtw88: replace tx tasklet with work queue")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  drivers/net/wireless/realtek/rtw88/main.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
> index 790dcfed1125..557213e52761 100644
> --- a/drivers/net/wireless/realtek/rtw88/main.c
> +++ b/drivers/net/wireless/realtek/rtw88/main.c
> @@ -2094,7 +2094,7 @@ int rtw_core_init(struct rtw_dev *rtwdev)
>  	ret = rtw_load_firmware(rtwdev, RTW_NORMAL_FW);
>  	if (ret) {
>  		rtw_warn(rtwdev, "no firmware loaded\n");
> -		return ret;
> +		goto destroy_workqueue;
>  	}
> 
>  	if (chip->wow_fw_name) {
> @@ -2104,11 +2104,15 @@ int rtw_core_init(struct rtw_dev *rtwdev)
>  			wait_for_completion(&rtwdev->fw.completion);
>  			if (rtwdev->fw.firmware)
>  				release_firmware(rtwdev->fw.firmware);
> -			return ret;
> +			goto destroy_workqueue;
>  		}
>  	}
> 
>  	return 0;
> +
> +destroy_workqueue:

It's not so good that the label 'destroy_workqueue' is the same as function name.
I suggest to just use 'out' instead.

> +	destroy_workqueue(rtwdev->tx_wq);
> +	return ret;
>  }
>  EXPORT_SYMBOL(rtw_core_init);
> 
> --
> 2.25.1
> 
> 
> ------Please consider the environment before printing this e-mail.
Yang Yingliang Aug. 26, 2022, 1:56 a.m. UTC | #2
Hi,

On 2022/8/26 8:44, Ping-Ke Shih wrote:
>> -----Original Message-----
>> From: Yang Yingliang <yangyingliang@huawei.com>
>> Sent: Thursday, August 25, 2022 9:38 PM
>> To: linux-kernel@vger.kernel.org; netdev@vger.kernel.org; linux-wireless@vger.kernel.org
>> Cc: tony0620emma@gmail.com; kvalo@kernel.org; Bernie Huang <phhuang@realtek.com>
>> Subject: [PATCH -next] wifi: rtw88: add missing destroy_workqueue() on error path in rtw_core_init()
>>
>> Add the missing destroy_workqueue() before return from rtw_core_init()
>> in error path.
>>
>> Fixes: fe101716c7c9 ("rtw88: replace tx tasklet with work queue")
>> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
>> ---
>>   drivers/net/wireless/realtek/rtw88/main.c | 8 ++++++--
>>   1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
>> index 790dcfed1125..557213e52761 100644
>> --- a/drivers/net/wireless/realtek/rtw88/main.c
>> +++ b/drivers/net/wireless/realtek/rtw88/main.c
>> @@ -2094,7 +2094,7 @@ int rtw_core_init(struct rtw_dev *rtwdev)
>>   	ret = rtw_load_firmware(rtwdev, RTW_NORMAL_FW);
>>   	if (ret) {
>>   		rtw_warn(rtwdev, "no firmware loaded\n");
>> -		return ret;
>> +		goto destroy_workqueue;
>>   	}
>>
>>   	if (chip->wow_fw_name) {
>> @@ -2104,11 +2104,15 @@ int rtw_core_init(struct rtw_dev *rtwdev)
>>   			wait_for_completion(&rtwdev->fw.completion);
>>   			if (rtwdev->fw.firmware)
>>   				release_firmware(rtwdev->fw.firmware);
>> -			return ret;
>> +			goto destroy_workqueue;
>>   		}
>>   	}
>>
>>   	return 0;
>> +
>> +destroy_workqueue:
> It's not so good that the label 'destroy_workqueue' is the same as function name.
> I suggest to just use 'out' instead.
How about 'out_destory_workqueue' ?

Thanks,
Yang
>
>> +	destroy_workqueue(rtwdev->tx_wq);
>> +	return ret;
>>   }
>>   EXPORT_SYMBOL(rtw_core_init);
>>
>> --
>> 2.25.1
>>
>>
>> ------Please consider the environment before printing this e-mail.
> .
Ping-Ke Shih Aug. 26, 2022, 2:01 a.m. UTC | #3
> -----Original Message-----
> From: Yang Yingliang <yangyingliang@huawei.com>
> Sent: Friday, August 26, 2022 9:57 AM
> To: Ping-Ke Shih <pkshih@realtek.com>; linux-kernel@vger.kernel.org; netdev@vger.kernel.org;
> linux-wireless@vger.kernel.org
> Cc: tony0620emma@gmail.com; kvalo@kernel.org; Bernie Huang <phhuang@realtek.com>
> Subject: Re: [PATCH -next] wifi: rtw88: add missing destroy_workqueue() on error path in rtw_core_init()
> 
> Hi,
> 
> On 2022/8/26 8:44, Ping-Ke Shih wrote:
> >> -----Original Message-----
> >> From: Yang Yingliang <yangyingliang@huawei.com>
> >> Sent: Thursday, August 25, 2022 9:38 PM
> >> To: linux-kernel@vger.kernel.org; netdev@vger.kernel.org; linux-wireless@vger.kernel.org
> >> Cc: tony0620emma@gmail.com; kvalo@kernel.org; Bernie Huang <phhuang@realtek.com>
> >> Subject: [PATCH -next] wifi: rtw88: add missing destroy_workqueue() on error path in rtw_core_init()
> >>
> >> Add the missing destroy_workqueue() before return from rtw_core_init()
> >> in error path.
> >>
> >> Fixes: fe101716c7c9 ("rtw88: replace tx tasklet with work queue")
> >> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> >> ---
> >>   drivers/net/wireless/realtek/rtw88/main.c | 8 ++++++--
> >>   1 file changed, 6 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
> >> index 790dcfed1125..557213e52761 100644
> >> --- a/drivers/net/wireless/realtek/rtw88/main.c
> >> +++ b/drivers/net/wireless/realtek/rtw88/main.c
> >> @@ -2094,7 +2094,7 @@ int rtw_core_init(struct rtw_dev *rtwdev)
> >>   	ret = rtw_load_firmware(rtwdev, RTW_NORMAL_FW);
> >>   	if (ret) {
> >>   		rtw_warn(rtwdev, "no firmware loaded\n");
> >> -		return ret;
> >> +		goto destroy_workqueue;
> >>   	}
> >>
> >>   	if (chip->wow_fw_name) {
> >> @@ -2104,11 +2104,15 @@ int rtw_core_init(struct rtw_dev *rtwdev)
> >>   			wait_for_completion(&rtwdev->fw.completion);
> >>   			if (rtwdev->fw.firmware)
> >>   				release_firmware(rtwdev->fw.firmware);
> >> -			return ret;
> >> +			goto destroy_workqueue;
> >>   		}
> >>   	}
> >>
> >>   	return 0;
> >> +
> >> +destroy_workqueue:
> > It's not so good that the label 'destroy_workqueue' is the same as function name.
> > I suggest to just use 'out' instead.
> How about 'out_destory_workqueue' ?
> 

Since there is only single one error case we need to handle, using 'out'
isn't ambiguous.
diff mbox series

Patch

diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
index 790dcfed1125..557213e52761 100644
--- a/drivers/net/wireless/realtek/rtw88/main.c
+++ b/drivers/net/wireless/realtek/rtw88/main.c
@@ -2094,7 +2094,7 @@  int rtw_core_init(struct rtw_dev *rtwdev)
 	ret = rtw_load_firmware(rtwdev, RTW_NORMAL_FW);
 	if (ret) {
 		rtw_warn(rtwdev, "no firmware loaded\n");
-		return ret;
+		goto destroy_workqueue;
 	}
 
 	if (chip->wow_fw_name) {
@@ -2104,11 +2104,15 @@  int rtw_core_init(struct rtw_dev *rtwdev)
 			wait_for_completion(&rtwdev->fw.completion);
 			if (rtwdev->fw.firmware)
 				release_firmware(rtwdev->fw.firmware);
-			return ret;
+			goto destroy_workqueue;
 		}
 	}
 
 	return 0;
+
+destroy_workqueue:
+	destroy_workqueue(rtwdev->tx_wq);
+	return ret;
 }
 EXPORT_SYMBOL(rtw_core_init);