• Alan Stern's avatar
    Driver core: fix race in __device_release_driver · ef2c5174
    Alan Stern authored
    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: default avatarAlan Stern <stern@rowland.harvard.edu>
    Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    ef2c5174
dd.c 8.96 KB