On Wed, Apr 13, 2005 at 09:40:17PM +0400, Roman Kagan wrote: > With 2.6.11 and 2.6.12-rc2 (and perhaps a few versions before) usb > drivers for multi-interface devices, which do > usb_driver_release_interface() in their disconnect(), make rmmod hang. > > It turns out to be due to a bug in drivers/base/bus.c:driver_detach(), > that iterates over the list of attached devices with > list_for_each_safe() under an assumption that device_release_driver() > only releases the current device, while it may also call > device_release_driver() for other devices on the same list.
A similar problem exists in -mm branch with klists. However, here it falls into several separate bugs: 1) an obvious typo: --- linux-2.6.12-rc2-mm3/drivers/usb/core/usb.c~ 2005-04-13 15:13:44.000000000 +0400 +++ linux-2.6.12-rc2-mm3/drivers/usb/core/usb.c 2005-04-13 19:33:54.000000000 +0400 @@ -323,7 +323,7 @@ void usb_driver_release_interface(struct return; /* don't disconnect from disconnect(), or before dev_add() */ - if (!klist_node_attached(&dev->knode_driver) && !klist_node_attached(&dev->knode_bus)) + if (klist_node_attached(&dev->knode_driver) && klist_node_attached(&dev->knode_bus)) device_release_driver(dev); dev->driver = NULL; 2) with klists, klist_del() in drivers/base/dd.c:device_release_driver(), when the latter is called from drivers/base/dd.c:driver_detach(), doesn't immediately delete the device from the list, because the node is referenced from the iteration. Therefore klist_node_attached(&dev->knode_driver) may be true in disconnect(), and thus can't protect from recursion into device_release_driver() 3) I'm yet unable to tell if the original problem of multiple list entries disappearing from under the list iteration also applies to klists - they seem to be too complex to me... Roman. ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel