Re: [PATCH] USB: core: document purpose of interface parent reference
From: Johan Hovold
Date: Thu Oct 15 2026 - 04:34:57 EST
On Thu, Oct 15, 2026 at 10:08:36AM +0200, Danilo Krummrich wrote:
> On Thu Oct 15, 2026 at 9:48 AM CEST, Johan Hovold wrote:
> > 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@xxxxxxxxxx>
>
> NIT: Maybe add that the reference count must be held until release().
I think that's implied as the comment refers to the lifetime of these
objects.
> In any case,
>
> Reviewed-by: Danilo Krummrich <dakr@xxxxxxxxxx>
Thanks for reviewing.
> > @@ -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);
> > }
Johan