diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 83d352394fdf..02f5aeadd8fd 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -1027,6 +1027,8 @@ static int __device_attach(struct device *dev, bool allow_async) ret = bus_for_each_drv(dev->bus, NULL, &data, __device_attach_driver); + if (!ret) + get_device(dev); if (!ret && allow_async && data.have_async) { /* * If we could not find appropriate driver @@ -1036,7 +1038,6 @@ static int __device_attach(struct device *dev, bool allow_async) * try them. */ dev_dbg(dev, "scheduling asynchronous probe\n"); - get_device(dev); async = true; } else { pm_request_idle(dev);