Skip to content

Commit 6548883

Browse files
l1kgregkh
authored andcommitted
driver core: Avoid binding drivers to dead devices
Commit 3451a49 ("driver core: Establish order of operations for device_add and device_del via bitflag") sought to prevent asynchronous driver binding to a device which is being removed. It added a per-device "dead" flag which is checked in the following code paths: * asynchronous binding in __driver_attach_async_helper() * synchronous binding in device_driver_attach() * asynchronous binding in __device_attach_async_helper() It did *not* check the flag upon: * synchronous binding in __device_attach() However __device_attach() may also be called asynchronously from: deferred_probe_work_func() bus_probe_device() device_initial_probe() __device_attach() So if the commit's intention was to check the "dead" flag in all asynchronous code paths, then a check is also necessary in __device_attach(). Add the missing check. Fixes: 3451a49 ("driver core: Establish order of operations for device_add and device_del via bitflag") Signed-off-by: Lukas Wunner <[email protected]> Cc: [email protected] # v5.1+ Cc: Alexander Duyck <[email protected]> Link: https://lore.kernel.org/r/de88a23a6fe0ef70f7cfd13c8aea9ab51b4edab6.1594214103.git.lukas@wunner.de Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent eea2c51 commit 6548883

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/base/dd.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,9 @@ static int __device_attach(struct device *dev, bool allow_async)
864864
int ret = 0;
865865

866866
device_lock(dev);
867-
if (dev->driver) {
867+
if (dev->p->dead) {
868+
goto out_unlock;
869+
} else if (dev->driver) {
868870
if (device_is_bound(dev)) {
869871
ret = 1;
870872
goto out_unlock;

0 commit comments

Comments
 (0)