Commit 5947956b authored by Thomas Vegas's avatar Thomas Vegas Committed by Greg Kroah-Hartman

staging: rtl8712: Fix oops on dongle removal if firmware is not available

When firmware is not available, net device is not created. Upon
disconnect, we must check for net device existence before trying to
release net device private data.
Signed-off-by: default avatarThomas Vegas <thomas@grouk.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5c3ddb3a
......@@ -607,9 +607,11 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf,
static void r871xu_dev_remove(struct usb_interface *pusb_intf)
{
struct net_device *pnetdev = usb_get_intfdata(pusb_intf);
struct _adapter *padapter = netdev_priv(pnetdev);
struct usb_device *udev = interface_to_usbdev(pusb_intf);
if (pnetdev) {
struct _adapter *padapter = netdev_priv(pnetdev);
usb_set_intfdata(pusb_intf, NULL);
if (padapter->fw_found)
release_firmware(padapter->fw);
......@@ -617,21 +619,19 @@ static void r871xu_dev_remove(struct usb_interface *pusb_intf)
wait_for_completion(&padapter->rtl8712_fw_ready);
if (drvpriv.drv_registered == true)
padapter->bSurpriseRemoved = true;
if (pnetdev != NULL) {
/* will call netdev_close() */
unregister_netdev(pnetdev);
}
unregister_netdev(pnetdev); /* will call netdev_close() */
flush_scheduled_work();
udelay(1);
/*Stop driver mlme relation timer */
/* Stop driver mlme relation timer */
if (padapter->fw_found)
r8712_stop_drv_timers(padapter);
r871x_dev_unload(padapter);
r8712_free_drv_sw(padapter);
usb_set_intfdata(pusb_intf, NULL);
/* decrease the reference count of the usb device structure
* when disconnect */
usb_put_dev(udev);
}
/* 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. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment