net: rtlwifi: properly check for alloc_workqueue() failure
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 3 May 2021 11:56:40 +0000 (13:56 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 May 2021 09:47:01 +0000 (11:47 +0200)
commit 30b0e0ee9d02b97b68705c46b41444786effc40c upstream.

If alloc_workqueue() fails, properly catch this and propagate the error
to the calling functions, so that the devuce initialization will
properly error out.

Cc: Kalle Valo <kvalo@codeaurora.org>
Cc: Bryan Brattlof <hello@bryanbrattlof.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210503115736.2104747-14-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireless/realtek/rtlwifi/base.c

index ec82c1c3f12e419642ffddcb9ad06b60571d25cc..55be9986ed54ea3897286e546714e195101313e5 100644 (file)
@@ -456,9 +456,14 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
        }
 }
 
-static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
+static int _rtl_init_deferred_work(struct ieee80211_hw *hw)
 {
        struct rtl_priv *rtlpriv = rtl_priv(hw);
+       struct workqueue_struct *wq;
+
+       wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name);
+       if (!wq)
+               return -ENOMEM;
 
        /* <1> timer */
        setup_timer(&rtlpriv->works.watchdog_timer,
@@ -467,7 +472,8 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
                    rtl_easy_concurrent_retrytimer_callback, (unsigned long)hw);
        /* <2> work queue */
        rtlpriv->works.hw = hw;
-       rtlpriv->works.rtl_wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name);
+       rtlpriv->works.rtl_wq = wq;
+
        INIT_DELAYED_WORK(&rtlpriv->works.watchdog_wq,
                          (void *)rtl_watchdog_wq_callback);
        INIT_DELAYED_WORK(&rtlpriv->works.ips_nic_off_wq,
@@ -480,7 +486,7 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
                          (void *)rtl_fwevt_wq_callback);
        INIT_DELAYED_WORK(&rtlpriv->works.c2hcmd_wq,
                          (void *)rtl_c2hcmd_wq_callback);
-
+       return 0;
 }
 
 void rtl_deinit_deferred_work(struct ieee80211_hw *hw, bool ips_wq)
@@ -580,9 +586,7 @@ int rtl_init_core(struct ieee80211_hw *hw)
        rtlmac->link_state = MAC80211_NOLINK;
 
        /* <6> init deferred work */
-       _rtl_init_deferred_work(hw);
-
-       return 0;
+       return _rtl_init_deferred_work(hw);
 }
 EXPORT_SYMBOL_GPL(rtl_init_core);