diff --git a/drivers/base/bus.c b/drivers/base/bus.c index f4fa27315fb4b69841ecf2a551d58d9a241c5546..2b3902c867dab76cf5b9b9d65d1778be20ac20e1 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -405,9 +405,8 @@ void device_release_driver(struct device * dev) static void driver_detach(struct device_driver * drv) { - struct list_head * entry, * next; - list_for_each_safe(entry, next, &drv->devices) { - struct device * dev = container_of(entry, struct device, driver_list); + while (!list_empty(&drv->devices)) { + struct device * dev = container_of(drv->devices.next, struct device, driver_list); device_release_driver(dev); } }