public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] driver core: fix deadlock in __driver_attach
@ 2022-06-08  9:43 Zhang Wensheng
  2022-06-10 13:49 ` Greg KH
  2022-06-16  7:11 ` zhangwensheng (E)
  0 siblings, 2 replies; 5+ messages in thread
From: Zhang Wensheng @ 2022-06-08  9:43 UTC (permalink / raw)
  To: gregkh, rafael; +Cc: linux-kernel, yukuai3, zhangwensheng5

In __driver_attach function, There are also potential AA deadlock
problem, like the commit b232b02bf3c2 ("driver core: fix deadlock
in __device_attach").

Fixes: ef0ff68351be ("driver core: Probe devices asynchronously instead of the driver")
Signed-off-by: Zhang Wensheng <zhangwensheng5@huawei.com>
---
 drivers/base/dd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 11b0fb6414d3..b766968a873c 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -1115,6 +1115,7 @@ static void __driver_attach_async_helper(void *_dev, async_cookie_t cookie)
 static int __driver_attach(struct device *dev, void *data)
 {
 	struct device_driver *drv = data;
+	bool async = false;
 	int ret;
 
 	/*
@@ -1153,9 +1154,11 @@ static int __driver_attach(struct device *dev, void *data)
 		if (!dev->driver && !dev->p->async_driver) {
 			get_device(dev);
 			dev->p->async_driver = drv;
-			async_schedule_dev(__driver_attach_async_helper, dev);
+			async = true;
 		}
 		device_unlock(dev);
+		if (async)
+			async_schedule_dev(__driver_attach_async_helper, dev);
 		return 0;
 	}
 
-- 
2.31.1


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

end of thread, other threads:[~2022-06-21 19:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-08  9:43 [PATCH -next] driver core: fix deadlock in __driver_attach Zhang Wensheng
2022-06-10 13:49 ` Greg KH
2022-06-16  8:00   ` zhangwensheng (E)
2022-06-21 19:34     ` Greg KH
2022-06-16  7:11 ` zhangwensheng (E)

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