[PATCH] usb: xhci: limit ports on the correct root hub

From: raoxu

Date: Wed Jun 03 2026 - 23:51:12 EST


From: Xu Rao <raoxu@xxxxxxxxxxxxx>

xhci_create_rhub_port_array() is used for both USB2 and USB3
root hubs. The limit path always writes usb3_rhub.num_ports.

When the helper limits the USB2 root hub, this leaves the passed
root hub unchanged and modifies the wrong root hub instead.

Limit the root hub passed to the helper so the cap is applied to
the root hub currently being initialized.

Fixes: 9a7ad750a8fb ("usb: xhci: move roothub port limit validation")
Signed-off-by: Xu Rao <raoxu@xxxxxxxxxxxxx>
---
drivers/usb/host/xhci-mem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

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);
}
--
2.50.1