[patch] bad locking in {driver,bus}_for_each_{drv,dev}

Arnd Bergmann (arnd@bergmann-dalldorf.de)
Thu, 13 Jun 2002 19:16:31 +0200


Hi,

I just ran in a deadlock in driver_for_each_dev, where read_unlock
was called without the lock being held. The patch below avoids the
problem there and in the other two places I found it.

Arnd <><

--- linux-2.5.21/drivers/base/driver.c Thu Jun 13 19:00:48 2002
+++ drivers/base/driver.c Thu Jun 13 19:01:25 2002
@@ -31,6 +31,7 @@
dev = next;
if ((error = callback(dev,data))) {
put_device(dev);
+ read_lock(&drv->lock);
break;
}
read_lock(&drv->lock);
--- linux-2.5.21/drivers/base/bus.c Thu Jun 13 19:05:25 2002
+++ drivers/base/bus.c Thu Jun 13 19:06:01 2002
@@ -61,6 +61,7 @@
dev = next;
if ((error = callback(dev,data))) {
put_device(dev);
+ read_lock(&bus->lock);
break;
}
read_lock(&bus->lock);
@@ -96,6 +97,7 @@
drv = next;
if ((error = callback(drv,data))) {
put_driver(drv);
+ read_lock(&bus->lock);
break;
}
read_lock(&bus->lock);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/