mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Driver core: fix race in __device_release_driver
@ 2007-11-16 16:57 Alan Stern
  2007-11-16 17:04 ` David Woodhouse
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Alan Stern @ 2007-11-16 16:57 UTC (permalink / raw)
  To: Greg KH, David Woodhouse; +Cc: USB development list, Kernel development list

This patch (as1013) was suggested by David Woodhouse; it fixes a race
in the driver core.  If a device is unregistered at the same time as
its driver is unloaded, the driver's code pages may be unmapped while
the remove method is still running.  The calls to get_driver() and
put_driver() were intended to prevent this, but they don't work if the
driver's module count has already dropped to 0.

Instead, the patch keeps the device on the driver's list until after
the remove method has returned.  This forces the necessary
synchronization to occur.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: David Woodhouse <dwmw2@infradead.org>

---

This should be considered for 2.6.24.


Index: usb-2.6/drivers/base/dd.c
===================================================================
--- usb-2.6.orig/drivers/base/dd.c
+++ usb-2.6/drivers/base/dd.c
@@ -289,11 +289,10 @@ static void __device_release_driver(stru
 {
 	struct device_driver * drv;
 
-	drv = get_driver(dev->driver);
+	drv = dev->driver;
 	if (drv) {
 		driver_sysfs_remove(dev);
 		sysfs_remove_link(&dev->kobj, "driver");
-		klist_remove(&dev->knode_driver);
 
 		if (dev->bus)
 			blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
@@ -306,7 +305,7 @@ static void __device_release_driver(stru
 			drv->remove(dev);
 		devres_release_all(dev);
 		dev->driver = NULL;
-		put_driver(drv);
+		klist_remove(&dev->knode_driver);
 	}
 }
 


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-11-27  7:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-16 16:57 [PATCH] Driver core: fix race in __device_release_driver Alan Stern
2007-11-16 17:04 ` David Woodhouse
2007-11-16 20:37 ` Greg KH
2007-11-16 20:45   ` David Woodhouse
2007-11-16 20:56     ` Greg KH
2007-11-16 20:48   ` Alan Stern
2007-11-27  7:14 ` patch driver-core-fix-race-in-__device_release_driver.patch added to gregkh-2.6 tree gregkh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®