[PATCH] libertas: don't oops on module unload after boot2 flash

Dan Williams dcbw at redhat.com
Thu Nov 2 14:14:37 EST 2006


if_usb_disconnect() was attempting to grab and dereference the usb
device private data, which under normal operation is a pointer to the
wlan_private structure for the card.  Under Boot2 operation, that
pointer is NULL because the card hasn't been set up for normal
operation.  The attached patch fixes this oops.

Signed-off-by: Dan Williams <dcbw at redhat.com>


diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
index 7bf979a..27818a9 100644
--- a/drivers/net/wireless/libertas/if_usb.c
+++ b/drivers/net/wireless/libertas/if_usb.c
@@ -359,17 +359,22 @@ static void if_usb_disconnect(struct usb
 {
 	struct usb_card_rec *cardp = usb_get_intfdata(intf);
 	wlan_private *priv = (wlan_private *) cardp->priv;
-	wlan_adapter *Adapter = priv->adapter;
+	wlan_adapter *Adapter = NULL;
 
 	ENTER();
 
 #ifdef SUPPORT_BOOT_COMMAND
 	if (UpdateStorage.u8DriverFunctionActive != DRIVER_NORMAL) {
 		us_usb_disconnect(intf);
-		LEAVE();
-		return ;
+		goto out;
 	}
 #endif
+
+	/* priv will only be allocated during normal operation,
+	 * but NOT doing a Boot2 firmware update.
+	 */
+	Adapter = priv->adapter;
+
 	/* 
 	 * Update Surprie removed to TRUE  
 	 *  Free all the URB's allocated 
@@ -388,6 +393,7 @@ #endif
 	usb_set_intfdata(intf, NULL);
 	usb_put_dev(interface_to_usbdev(intf));
 
+out:
 	LEAVE();
 	return;
 }





More information about the libertas-dev mailing list