Linux USB
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Danilo Krummrich <dakr@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] USB: core: document purpose of interface parent reference
Date: Thu, 15 Oct 2026 10:28:27 +0200	[thread overview]
Message-ID: <atCOq_kAAoUzKGRw@hovoldconsulting.com> (raw)
In-Reply-To: <DM59BD7BDUHZ.2BON4KMXDR086@kernel.org>

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@kernel.org>
> 
> 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@kernel.org>

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

      reply	other threads:[~2026-10-15  8:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=atCOq_kAAoUzKGRw@hovoldconsulting.com \
    --to=johan@kernel.org \
    --cc=dakr@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox