From: sashiko-bot@kernel.org
To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org
Subject: Re: [PATCH 17/19] usb: renesas_usbhs: unlink the URB if it is not queued
Date: Tue, 27 Oct 2026 15:27:21 +0000 [thread overview]
Message-ID: <sashiko-outbox-186834@kernel.org> (raw)
In-Reply-To: <20261027-llm-usb-v1-17-b9751ddb9c7c@linuxfoundation.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] usb: renesas_usbhs: new_udev leak in usbhsh_urb_enqueue() on queue push error
--
commit 3025db27a621582451ab2718c744f405f863e1c5
Author: Josef Bacik <josef@toxicpanda.com>
usb: renesas_usbhs: unlink the URB if it is not queued
This commit fixes usbhsh_urb_enqueue() to unlink the URB from its endpoint
and detach the pipe when queueing fails, preventing list corruption and pipe
use count leaks on enqueue errors.
> diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c
> index 0652525d06fec..bdec4eaf34027 100644
> --- a/drivers/usb/renesas_usbhs/mod_host.c
> +++ b/drivers/usb/renesas_usbhs/mod_host.c
> @@ -987,7 +987,7 @@ static int usbhsh_urb_enqueue(struct usb_hcd *hcd,
> if (!new_udev) {
> ret = -EIO;
> dev_err(dev, "device attach failed\n");
> - goto usbhsh_urb_enqueue_error_not_linked;
> + goto usbhsh_urb_enqueue_error_unlink;
> }
> }
>
> @@ -1020,14 +1020,22 @@ static int usbhsh_urb_enqueue(struct usb_hcd *hcd,
> ret = usbhsh_dcp_queue_push(hcd, urb, mem_flags);
> else
> ret = usbhsh_queue_push(hcd, urb, mem_flags);
> + if (ret < 0) {
> + usbhsh_pipe_detach(hpriv, usbhsh_ep_to_uep(ep));
> + goto usbhsh_urb_enqueue_error_unlink;
> + }
>
> - return ret;
> + return 0;
>
> usbhsh_urb_enqueue_error_free_endpoint:
> usbhsh_endpoint_detach(hpriv, ep);
> usbhsh_urb_enqueue_error_free_device:
> if (new_udev)
> usbhsh_device_detach(hpriv, new_udev);
> +usbhsh_urb_enqueue_error_unlink:
[Severity: High]
Can jumping directly to usbhsh_urb_enqueue_error_unlink when
usbhsh_dcp_queue_push() or usbhsh_queue_push() fails leak the newly attached
new_udev slot in hpriv->udev[] and leave a dangling pointer in
new_udev->usbv?
When the first URB is submitted to a newly connected device at address 0,
usbhsh_urb_enqueue() allocates new_udev via usbhsh_device_attach(), which
claims a slot in hpriv->udev[] and sets new_udev->usbv = usbv.
Next, usbhsh_endpoint_attach() attaches ep0's struct usbhsh_ep to the device
returned by usbhsh_device_get():
drivers/usb/renesas_usbhs/mod_host.c:usbhsh_device_get() {
...
/* if it is device0, return it */
if (0 == usb_pipedevice(urb->pipe))
return usbhsh_device0(hpriv);
...
}
Because the device is still at address 0, ep0's endpoint is linked onto
udev0 rather than new_udev.
If usbhsh_dcp_queue_push() or usbhsh_queue_push() then fails, jumping to
usbhsh_urb_enqueue_error_unlink skips usbhsh_urb_enqueue_error_free_endpoint
and usbhsh_urb_enqueue_error_free_device. When enumeration later aborts and
usbhsh_endpoint_disable() runs for ep0, it only sees udev0 and calls
usbhsh_device_detach(hpriv, udev0), which returns early without detaching
new_udev:
drivers/usb/renesas_usbhs/mod_host.c:usbhsh_device_detach() {
...
if (0 == usbhsh_device_number(hpriv, udev))
return;
...
}
Should this error path jump to usbhsh_urb_enqueue_error_free_endpoint (which
also calls usbhsh_pipe_detach() if a pipe is attached) or otherwise ensure
new_udev is detached?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261027-llm-usb-v1-0-b9751ddb9c7c@linuxfoundation.org?part=17
next prev parent reply other threads:[~2026-10-27 15:27 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 14:57 [PATCH 00/19] USB: a bunch of llm-found fixes Greg Kroah-Hartman
2026-10-27 14:57 ` [PATCH 01/19] usb: core: sysfs: take the port lock to read the BOS Greg Kroah-Hartman
2026-10-27 15:10 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 02/19] USB: core: signal the end of an sg request last Greg Kroah-Hartman
2026-10-27 15:04 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 03/19] usbip: vudc: free the unlink item if the send fails Greg Kroah-Hartman
2026-10-27 15:09 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 04/19] usb: host: oxu210hp-hcd: fix oxu_qh_alloc() deadlock Greg Kroah-Hartman
2026-10-27 15:06 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 05/19] usb: cdns3: switch the role unlocked on resume Greg Kroah-Hartman
2026-10-27 15:27 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 06/19] usb: gadget: snps_udc_plat: lock out the interrupt Greg Kroah-Hartman
2026-10-27 15:05 ` sashiko-bot
2026-10-27 18:17 ` Herve Codina
2026-10-27 14:57 ` [PATCH 07/19] usb: gadget: bdc: the resume callback is optional Greg Kroah-Hartman
2026-10-27 15:06 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 08/19] usb: gadget: uvc: fix oops on a premature STREAMON Greg Kroah-Hartman
2026-10-27 15:22 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 09/19] usb: gadget: f_fs: let the request keep its fence Greg Kroah-Hartman
2026-10-27 15:15 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 10/19] usb: host: ehci-orion: fix the probe without DT Greg Kroah-Hartman
2026-10-27 15:09 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 11/19] usb: typec: tcpm: don't wait for the VDM discovery work Greg Kroah-Hartman
2026-10-27 15:18 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 12/19] usb: typec: tcpci: don't act on unread alerts Greg Kroah-Hartman
2026-10-27 15:12 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 13/19] usb: typec: anx7411: zero on-stack alt mode descriptors Greg Kroah-Hartman
2026-10-27 15:10 ` sashiko-bot
2026-10-28 16:20 ` Benson Leung
2026-10-27 14:57 ` [PATCH 14/19] usb: typec: mux: it5205: fix oops on accessory modes Greg Kroah-Hartman
2026-10-27 15:13 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 15/19] usb: typec: mux: tusb1046: " Greg Kroah-Hartman
2026-10-27 15:13 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 16/19] usb: renesas_usbhs: link URBs with interrupts disabled Greg Kroah-Hartman
2026-10-27 15:23 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 17/19] usb: renesas_usbhs: unlink the URB if it is not queued Greg Kroah-Hartman
2026-10-27 15:27 ` sashiko-bot [this message]
2026-10-27 14:57 ` [PATCH 18/19] usb: isp1760: wait for the TT clear in endpoint_disable Greg Kroah-Hartman
2026-10-27 15:21 ` Rui Miguel Silva
2026-10-27 15:28 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 19/19] usb: dwc2: " Greg Kroah-Hartman
2026-10-27 15:37 ` sashiko-bot
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=sashiko-outbox-186834@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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