Commit:     ef2c51746dc89c2326ce522f8fb8a57695780e75
Parent:     c8e90d822bff3e0502d004facedb05859f98055f
Author:     Alan Stern <[EMAIL PROTECTED]>
AuthorDate: Fri Nov 16 11:57:28 2007 -0500
Committer:  Greg Kroah-Hartman <[EMAIL PROTECTED]>
CommitDate: Thu Jan 24 20:40:35 2008 -0800

    Driver core: fix race in __device_release_driver
    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 <[EMAIL PROTECTED]>
    Signed-off-by: David Woodhouse <[EMAIL PROTECTED]>
    Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
 drivers/base/dd.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 5492264..b0726eb 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -289,11 +289,10 @@ static void __device_release_driver(struct device * dev)
        struct device_driver * drv;
-       drv = get_driver(dev->driver);
+       drv = dev->driver;
        if (drv) {
                sysfs_remove_link(&dev->kobj, "driver");
-               klist_remove(&dev->knode_driver);
                if (dev->bus)
@@ -306,7 +305,7 @@ static void __device_release_driver(struct device * dev)
                dev->driver = NULL;
-               put_driver(drv);
+               klist_remove(&dev->knode_driver);
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to