Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: rtlwifi: properly check for alloc_workqueue() failure

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>

+10 -5
+10 -5
drivers/net/wireless/realtek/rtlwifi/base.c
··· 440 440 static void rtl_fwevt_wq_callback(struct work_struct *work); 441 441 static void rtl_c2hcmd_wq_callback(struct work_struct *work); 442 442 443 - static void _rtl_init_deferred_work(struct ieee80211_hw *hw) 443 + static int _rtl_init_deferred_work(struct ieee80211_hw *hw) 444 444 { 445 445 struct rtl_priv *rtlpriv = rtl_priv(hw); 446 + struct workqueue_struct *wq; 447 + 448 + wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name); 449 + if (!wq) 450 + return -ENOMEM; 446 451 447 452 /* <1> timer */ 448 453 timer_setup(&rtlpriv->works.watchdog_timer, ··· 456 451 rtl_easy_concurrent_retrytimer_callback, 0); 457 452 /* <2> work queue */ 458 453 rtlpriv->works.hw = hw; 459 - rtlpriv->works.rtl_wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name); 454 + rtlpriv->works.rtl_wq = wq; 455 + 460 456 INIT_DELAYED_WORK(&rtlpriv->works.watchdog_wq, 461 457 rtl_watchdog_wq_callback); 462 458 INIT_DELAYED_WORK(&rtlpriv->works.ips_nic_off_wq, ··· 467 461 rtl_swlps_rfon_wq_callback); 468 462 INIT_DELAYED_WORK(&rtlpriv->works.fwevt_wq, rtl_fwevt_wq_callback); 469 463 INIT_DELAYED_WORK(&rtlpriv->works.c2hcmd_wq, rtl_c2hcmd_wq_callback); 464 + return 0; 470 465 } 471 466 472 467 void rtl_deinit_deferred_work(struct ieee80211_hw *hw, bool ips_wq) ··· 566 559 rtlmac->link_state = MAC80211_NOLINK; 567 560 568 561 /* <6> init deferred work */ 569 - _rtl_init_deferred_work(hw); 570 - 571 - return 0; 562 + return _rtl_init_deferred_work(hw); 572 563 } 573 564 EXPORT_SYMBOL_GPL(rtl_init_core); 574 565