Skip to content

Commit b2d84f0

Browse files
rvkagregkh
authored andcommitted
[PATCH] drivers/base/bus.c: fix iteration in driver_detach()
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. The following patch fixes it. Please consider applying. Signed-off-by: Roman Kagan <rkagan@mail.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 177a432 commit b2d84f0

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎drivers/base/bus.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,8 @@ void device_release_driver(struct device * dev)
405405

406406
static void driver_detach(struct device_driver * drv)
407407
{
408-
struct list_head * entry, * next;
409-
list_for_each_safe(entry, next, &drv->devices) {
410-
struct device * dev = container_of(entry, struct device, driver_list);
408+
while (!list_empty(&drv->devices)) {
409+
struct device * dev = container_of(drv->devices.next, struct device, driver_list);
411410
device_release_driver(dev);
412411
}
413412
}

0 commit comments

Comments
 (0)