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

From: Arnd Bergmann (arnd@bergmann-dalldorf.de)
Date: Thu Jun 13 2002 - 12:16:31 EST


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/



This archive was generated by hypermail 2b29 : Sat Jun 15 2002 - 22:00:28 EST