PATCH: (as279) Don't delete interfaces until all are unbound
From: Alan Stern
Date: Thu May 13 2004 - 12:58:38 EST
On Thu, 13 May 2004, Duncan Sands wrote:
> No, but the pointer for another (previous) interface may just have been
> set to NULL, causing an Oops when usb_ifnum_to_if loops over all
> interfaces.
Of course! I trust you won't mind me changing your suggested fix
slightly. This should do an equally good job of repairing things, and it
will prevent other possible invalid references as well.
Greg, please apply.
Alan Stern
===== drivers/usb/core/message.c 1.83 vs edited =====
--- 1.83/drivers/usb/core/message.c Mon May 3 06:26:40 2004
+++ edited/drivers/usb/core/message.c Thu May 13 13:37:48 2004
@@ -830,7 +830,14 @@
interface = dev->actconfig->interface[i];
dev_dbg (&dev->dev, "unregistering interface %s\n",
interface->dev.bus_id);
- device_unregister (&interface->dev);
+ device_del (&interface->dev);
+ }
+
+ /* Now that the interfaces are unbound, nobody should
+ * try to access them.
+ */
+ for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) {
+ put_device (&dev->actconfig->interface[i]->dev);
dev->actconfig->interface[i] = NULL;
}
dev->actconfig = 0;
===== drivers/usb/core/usb.c 1.264 vs edited =====
--- 1.264/drivers/usb/core/usb.c Thu Apr 15 08:19:20 2004
+++ edited/drivers/usb/core/usb.c Thu May 13 13:40:06 2004
@@ -198,6 +198,9 @@
* This routine helps device drivers avoid such mistakes.
* However, you should make sure that you do the right thing with any
* alternate settings available for this interfaces.
+ *
+ * Don't call this function unless you are bound to one of the interfaces
+ * on this device or you own the dev->serialize semaphore!
*/
struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum)
{
@@ -228,6 +231,9 @@
* it would be incorrect to assume that the first altsetting entry in
* the array corresponds to altsetting zero. This routine helps device
* drivers avoid such mistakes.
+ *
+ * Don't call this function unless you are bound to the intf interface
+ * or you own the device's ->serialize semaphore!
*/
struct usb_host_interface *usb_altnum_to_altsetting(struct usb_interface *intf,
unsigned int altnum)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/