mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] driver core: unbind consumers before locking parent on device unbind
@ 2017-02-17 18:36 Lucas Stach
  2017-02-17 18:42 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Lucas Stach @ 2017-02-17 18:36 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, patchwork-lst, kernel

On forced unbind the parent lock is taken, as the device might be a USB
device. The device to be unbound might have active consumers, which
must be unbound before calling device_release_driver(), otherwise this
function might deadlock when trying to take the parent lock during
consumer unbind.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/base/bus.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 6470eb8088f4..23df171a6a64 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -186,6 +186,9 @@ static ssize_t unbind_store(struct device_driver *drv, const char *buf,
 
 	dev = bus_find_device_by_name(bus, NULL, buf);
 	if (dev && dev->driver == drv) {
+		while (device_links_busy(dev)) {
+			device_links_unbind_consumers(dev);
+		}
 		if (dev->parent)	/* Needed for USB */
 			device_lock(dev->parent);
 		device_release_driver(dev);
-- 
2.11.0

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

end of thread, other threads:[~2017-02-17 18:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-17 18:36 [PATCH] driver core: unbind consumers before locking parent on device unbind Lucas Stach
2017-02-17 18:42 ` Greg Kroah-Hartman
2017-02-17 18:46   ` Lucas Stach

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

all inboxes | Powered by JetHome®