Skip to contentSkip to conversation

fix race condition in drivers/base/dd.c

PATCH In review Stefani Seibold 2 participants 3 messages Mar 6, 2010 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix race condition in drivers/base/dd.c

This patch fix a potential race condition in the driver_bound() function in the file driver/base/dd.c.

The broadcast of the BUS_NOTIFY_BOUND_DRIVER notifier should be done after adding the new device to the driver list. Otherwise notifier listener will fail if they use functions like usb_find_interface().

The patch is against kernel 2.6.33. Please merge it.

---
 dd.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/base/dd.c +2 -2
@@ -40,11 +40,11 @@ static void driver_bound(struct device *
 	pr_debug("driver: '%s': %s: bound to device '%s'\n", dev_name(dev),
 		 __func__, dev->driver->name);
 
+	klist_add_tail(&dev->p->knode_driver, &dev->driver->p->klist_devices);
+
 	if (dev->bus)
 		blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
 					     BUS_NOTIFY_BOUND_DRIVER, dev);
-
-	klist_add_tail(&dev->p->knode_driver, &dev->driver->p->klist_devices);
 }
 
 static int driver_sysfs_add(struct device *dev)
#1 lore raw
Quoted 8 lines · Stefani Seibold

This patch fix a potential race condition in the driver_bound() function in the file driver/base/dd.c.

The broadcast of the BUS_NOTIFY_BOUND_DRIVER notifier should be done after adding the new device to the driver list. Otherwise notifier listener will fail if they use functions like usb_find_interface().

The patch is against kernel 2.6.33. Please merge it.

Looks good, are there bugs caused by this problem today that require this patch to be backported to the -stable kernels?

thanks,

greg k-h

#2 lore raw

Am Samstag, den 06.03.2010, 08:57 -0800 schrieb Greg KH:

Quoted 13 lines · Stefani Seibold
Quoted 8 lines

This patch fix a potential race condition in the driver_bound() function in the file driver/base/dd.c.

The broadcast of the BUS_NOTIFY_BOUND_DRIVER notifier should be done after adding the new device to the driver list. Otherwise notifier listener will fail if they use functions like usb_find_interface().

The patch is against kernel 2.6.33. Please merge it.

Looks good, are there bugs caused by this problem today that require this patch to be backported to the -stable kernels?

No, there is no problem in the stable kernel. There was only a problem with one of my out of tree driver.

Stefani