diff mbox series

net: rtlwifi: fix a potential NULL pointer dereference

Message ID 20190312075633.573-1-kjlu@umn.edu (mailing list archive)
State Accepted
Commit 765976285a8c8db3f0eb7f033829a899d0c2786e
Delegated to: Kalle Valo
Headers show
Series net: rtlwifi: fix a potential NULL pointer dereference | expand

Commit Message

Kangjie Lu March 12, 2019, 7:56 a.m. UTC
In case alloc_workqueue fails, the fix reports the error and
returns to avoid NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/net/wireless/realtek/rtlwifi/base.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Kangjie Lu March 23, 2019, 3:59 a.m. UTC | #1
> On Mar 12, 2019, at 2:56 AM, Kangjie Lu <kjlu@umn.edu> wrote:
> 
> In case alloc_workqueue fails, the fix reports the error and
> returns to avoid NULL pointer dereference.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/net/wireless/realtek/rtlwifi/base.c | 5 +++++
> 1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c b/drivers/net/wireless/realtek/rtlwifi/base.c
> index 217d2a7a43c7..ac746c322554 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/base.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/base.c
> @@ -448,6 +448,11 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
> 	/* <2> work queue */
> 	rtlpriv->works.hw = hw;
> 	rtlpriv->works.rtl_wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name);
> +	if (unlikely(!rtlpriv->works.rtl_wq)) {
> +		pr_err("Failed to allocate work queue\n");
> +		return;
> +	}
> +

Can someone review the patch?

Thanks.

> 	INIT_DELAYED_WORK(&rtlpriv->works.watchdog_wq,
> 			  (void *)rtl_watchdog_wq_callback);
> 	INIT_DELAYED_WORK(&rtlpriv->works.ips_nic_off_wq,
> -- 
> 2.17.1
>
Kalle Valo March 23, 2019, 6:40 a.m. UTC | #2
Kangjie Lu <kjlu@umn.edu> writes:

>> On Mar 12, 2019, at 2:56 AM, Kangjie Lu <kjlu@umn.edu> wrote:
>> 
>> In case alloc_workqueue fails, the fix reports the error and
>> returns to avoid NULL pointer dereference.
>> 
>> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
>> ---
>> drivers/net/wireless/realtek/rtlwifi/base.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>> 
>> diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c
>> b/drivers/net/wireless/realtek/rtlwifi/base.c
>> index 217d2a7a43c7..ac746c322554 100644
>> --- a/drivers/net/wireless/realtek/rtlwifi/base.c
>> +++ b/drivers/net/wireless/realtek/rtlwifi/base.c
>> @@ -448,6 +448,11 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
>> 	/* <2> work queue */
>> 	rtlpriv->works.hw = hw;
>> 	rtlpriv->works.rtl_wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name);
>> +	if (unlikely(!rtlpriv->works.rtl_wq)) {
>> +		pr_err("Failed to allocate work queue\n");
>> +		return;
>> +	}
>> +
>
> Can someone review the patch?

wireless-drivers-next is not yet open due to the wireless workshop. Also
you can check the patch status yourself:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches#checking_state_of_patches_from_patchwork
Kalle Valo April 4, 2019, 10:25 a.m. UTC | #3
Kangjie Lu <kjlu@umn.edu> wrote:

> In case alloc_workqueue fails, the fix reports the error and
> returns to avoid NULL pointer dereference.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>

Patch applied to wireless-drivers-next.git, thanks.

765976285a8c rtlwifi: fix a potential NULL pointer dereference
diff mbox series

Patch

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c b/drivers/net/wireless/realtek/rtlwifi/base.c
index 217d2a7a43c7..ac746c322554 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -448,6 +448,11 @@  static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
 	/* <2> work queue */
 	rtlpriv->works.hw = hw;
 	rtlpriv->works.rtl_wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name);
+	if (unlikely(!rtlpriv->works.rtl_wq)) {
+		pr_err("Failed to allocate work queue\n");
+		return;
+	}
+
 	INIT_DELAYED_WORK(&rtlpriv->works.watchdog_wq,
 			  (void *)rtl_watchdog_wq_callback);
 	INIT_DELAYED_WORK(&rtlpriv->works.ips_nic_off_wq,