Commit b2d84f07 authored by Roman Kagan's avatar Roman Kagan Committed by Greg KH

[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: default avatarRoman Kagan <rkagan@mail.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 177a4324
...@@ -405,9 +405,8 @@ void device_release_driver(struct device * dev) ...@@ -405,9 +405,8 @@ void device_release_driver(struct device * dev)
static void driver_detach(struct device_driver * drv) static void driver_detach(struct device_driver * drv)
{ {
struct list_head * entry, * next; while (!list_empty(&drv->devices)) {
list_for_each_safe(entry, next, &drv->devices) { struct device * dev = container_of(drv->devices.next, struct device, driver_list);
struct device * dev = container_of(entry, struct device, driver_list);
device_release_driver(dev); device_release_driver(dev);
} }
} }
......
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