Linux USB
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Johan Hovold" <johan@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:08:36 +0200	[thread overview]
Message-ID: <DM59BD7BDUHZ.2BON4KMXDR086@kernel.org> (raw)
In-Reply-To: <20261015074831.1418677-1-johan@kernel.org>

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().

In any case,

Reviewed-by: Danilo Krummrich <dakr@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


  parent reply	other threads:[~2026-10-15  8:08 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 [this message]
2026-10-15  8:28   ` Johan Hovold

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=DM59BD7BDUHZ.2BON4KMXDR086@kernel.org \
    --to=dakr@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.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