From: Ginger Li <ginger.jzllee@gmail.com>
To: gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] USB: core: Fix unlocked hcd->status_urb access in usb_hcd_poll_rh_status()
Date: Wed, 23 Sep 2026 16:38:28 +0800 [thread overview]
Message-ID: <20260923083828.64925-1-ginger.jzllee@gmail.com> (raw)
usb_hcd_poll_rh_status() tests hcd->status_urb without holding
hcd_root_hub_lock, while rh_queue_status() and the completion path inside
usb_hcd_poll_rh_status() itself update that field under the lock.
Take hcd_root_hub_lock around the early bail-out check so that the read is
serialized with the writers.
Fixes: d5926ae7a827 ("[PATCH] usbcore support for root-hub IRQ instead of polling")
Signed-off-by: Ginger Li <ginger.jzllee@gmail.com>
---
drivers/usb/core/hcd.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -727,8 +727,13 @@ void usb_hcd_poll_rh_status(struct usb_hcd *hcd)
if (unlikely(!hcd->rh_pollable))
return;
- if (!hcd->uses_new_polling && !hcd->status_urb)
+
+ spin_lock_irqsave(&hcd_root_hub_lock, flags);
+ if (!hcd->uses_new_polling && !hcd->status_urb) {
+ spin_unlock_irqrestore(&hcd_root_hub_lock, flags);
return;
+ }
+ spin_unlock_irqrestore(&hcd_root_hub_lock, flags);
length = hcd->driver->hub_status_data(hcd, buffer);
if (length > 0) {
--
2.43.0
next reply other threads:[~2026-09-23 8:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 8:38 Ginger Li [this message]
2026-09-23 9:23 ` Greg KH
2026-09-23 14:03 ` Alan Stern
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=20260923083828.64925-1-ginger.jzllee@gmail.com \
--to=ginger.jzllee@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/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
all inboxes | Powered by JetHome®