patch "staging: rtl8712: handle firmware load failure" added to staging-next
Subsystems (2)
This is a note to let you know that I've just added the patch titled
staging: rtl8712: handle firmware load failure
to my staging git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-next branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will also be merged in the next major kernel release during the merge window.
If you have any questions about this process, please let me know.
From b4383c971bc5263efe2b0915ba67ebf2bf3f1ee5 Mon Sep 17 00:00:00 2001
From: Rustam Kovhaev <[email protected]>
Date: Thu, 16 Jul 2020 08:13:26 -0700
Subject: staging: rtl8712: handle firmware load failure
when firmware fails to load we should not call unregister_netdev() this patch fixes a race condition between rtl871x_load_fw_cb() and r871xu_dev_remove() and fixes the bug reported by syzbot
--- drivers/staging/rtl8712/hal_init.c | 3 ++- drivers/staging/rtl8712/usb_intf.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-)
drivers/staging/rtl8712/hal_init.c +2 -1
@@ -33,7 +33,6 @@ static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context) {struct _adapter *adapter = context; -complete (&adapter->rtl8712_fw_ready);if (!firmware) {struct usb_device *udev = adapter->dvobjpriv.pusbdev;struct usb_interface *usb_intf = adapter->pusb_intf;
@@ -41,11 +40,13 @@ static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context)dev_err (&udev->dev,"r8712u: Firmware request failed\n" );usb_put_dev (udev);usb_set_intfdata (usb_intf,NULL ); +complete (&adapter->rtl8712_fw_ready);return ; } adapter->fw = firmware;/* firmware available - start netdev */ register_netdev (adapter->pnetdev); +complete (&adapter->rtl8712_fw_ready); }static const char firmware_file[] ="rtlwifi/rtl8712u.bin" ;
drivers/staging/rtl8712/usb_intf.c +8 -3
@@ -595,13 +595,17 @@ static void r871xu_dev_remove(struct usb_interface *pusb_intf)if (pnetdev) {struct _adapter *padapter =netdev_priv (pnetdev); -usb_set_intfdata (pusb_intf,NULL ); -release_firmware (padapter->fw);/* never exit with a firmware callback pending */ wait_for_completion (&padapter->rtl8712_fw_ready); + pnetdev =usb_get_intfdata (pusb_intf); +usb_set_intfdata (pusb_intf,NULL ); +if (!pnetdev) + goto firmware_load_fail; +release_firmware (padapter->fw);if (drvpriv.drv_registered) padapter->surprise_removed = true; -unregister_netdev (pnetdev);/* will call netdev_close() */ +if (pnetdev->reg_state !=NETREG_UNINITIALIZED ) +unregister_netdev (pnetdev);/* will call netdev_close() */ flush_scheduled_work ();udelay (1 );/* Stop driver mlme relation timer */
@@ -614,6 +618,7 @@ static void r871xu_dev_remove(struct usb_interface *pusb_intf)*/ usb_put_dev (udev); } +firmware_load_fail:/* If we didn't unplug usb dongle and remove/insert module, driver * fails on sitesurvey for the first time when device is up. * Reset usb port for sitesurvey fail issue.
Signature · 1 line
2.27.0