All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] USB: core: document purpose of interface parent reference
@ 2026-10-15  7:48 Johan Hovold
  2026-10-15  7:59 ` sashiko-bot
  2026-10-15  8:08 ` Danilo Krummrich
  0 siblings, 2 replies; 4+ messages in thread
From: Johan Hovold @ 2026-10-15  7:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Alan Stern, Danilo Krummrich, linux-usb, linux-kernel,
	Johan Hovold

USB interfaces hold a reference to their parent USB device to make sure
they do not outlive the parent.

Add a comment explaining that this reference is specifically needed for
asynchronous device resets and the device type need_parent_lock feature
(to allow driver core to lock the parent when only holding a reference
to the interface).

See commits:

  524134d42231 ("USB: don't cancel queued resets when unbinding drivers")
  af61396a992b ("driver core: fix parent lock use-after-free on USB disconnect")

for further details.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/core/message.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 276768f47558..a738d03c23ea 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -2209,6 +2209,11 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
 		pm_runtime_no_callbacks(&intf->dev);
 		dev_set_name(&intf->dev, "%d-%s:%d.%d", dev->bus->busnum,
 				dev->devpath, configuration, ifnum);
+		/*
+		 * Make sure the interface does not outlive its parent (e.g.
+		 * as needed for usb_queue_reset_device() and
+		 * usb_if_device_type->need_parent_lock).
+		 */
 		usb_get_dev(dev);
 	}
 	kfree(new_interfaces);
-- 
2.55.0


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

end of thread, other threads:[~2026-10-15  8:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-15  7:48 [PATCH] USB: core: document purpose of interface parent reference Johan Hovold
2026-10-15  7:59 ` sashiko-bot
2026-10-15  8:08 ` Danilo Krummrich
2026-10-15  8:28   ` Johan Hovold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.