From: Zhang Cen <rollkingzzc@gmail.com>
To: Mathias Nyman <mathias.nyman@intel.com>
Cc: linux-usb@vger.kernel.org, zerocling0077@gmail.com,
2045gemini@gmail.com, Zhang Cen <rollkingzzc@gmail.com>
Subject: [PATCH] usb: xhci: fix USB2 roothub port count clamp
Date: Sat, 16 May 2026 11:34:43 +0800 [thread overview]
Message-ID: <20260516033443.3646966-1-rollkingzzc@gmail.com> (raw)
xhci_create_rhub_port_array() is passed the roothub whose port array is
being built and the limit that matches that roothub's descriptor size. The
limit check currently stores the clamped value in xhci->usb3_rhub.num_ports
unconditionally.
When this helper handles the USB2 roothub, a controller advertising more
than USB_MAXCHILDREN USB2 ports leaves xhci->usb2_rhub.num_ports unchanged.
Later USB2 hub descriptor and status helpers use that count to size fixed
USB2 descriptor and status bitmaps.
Clamp the roothub passed to the helper so both USB2 and USB3 counts are
bounded before those paths use them.
Fixes: 9a7ad750a8fb ("usb: xhci: move roothub port limit validation")
Signed-off-by: Zhang Cen <rollkingzzc@gmail.com>
---
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 997fe90f54e5..2545f96fd1ee 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -2182,7 +2182,7 @@ static void xhci_create_rhub_port_array(struct xhci_hcd *xhci, struct xhci_hub *
* descriptors aren't longer than the USB core will allocate.
*/
if (rhub->num_ports > max_ports) {
- xhci->usb3_rhub.num_ports = max_ports;
+ rhub->num_ports = max_ports;
xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Limiting USB%u root hub ports to %u",
rhub->maj_rev, max_ports);
}
reply other threads:[~2026-05-16 3:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260516033443.3646966-1-rollkingzzc@gmail.com \
--to=rollkingzzc@gmail.com \
--cc=2045gemini@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=zerocling0077@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.