* [PATCH] usb: xhci: limit ports on the correct root hub
@ 2026-06-04 3:48 raoxu
2026-06-04 6:51 ` Michal Pecio
0 siblings, 1 reply; 3+ messages in thread
From: raoxu @ 2026-06-04 3:48 UTC (permalink / raw)
To: mathias.nyman; +Cc: gregkh, linux-usb, linux-kernel, raoxu
From: Xu Rao <raoxu@uniontech.com>
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@uniontech.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: xhci: limit ports on the correct root hub
2026-06-04 3:48 [PATCH] usb: xhci: limit ports on the correct root hub raoxu
@ 2026-06-04 6:51 ` Michal Pecio
2026-06-04 7:11 ` raoxu
0 siblings, 1 reply; 3+ messages in thread
From: Michal Pecio @ 2026-06-04 6:51 UTC (permalink / raw)
To: raoxu
Cc: mathias.nyman, gregkh, linux-usb, linux-kernel, Zhang Cen,
Niklas Neronin
On Thu, 4 Jun 2026 11:48:18 +0800, raoxu wrote:
> From: Xu Rao <raoxu@uniontech.com>
>
> 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@uniontech.com>
Previous patch for the same bug, Cc its author and bad commit author.
https://lore.kernel.org/linux-usb/20260516033443.3646966-1-rollkingzzc@gmail.com/
I'm not sure how people keep discovering this issue - only by review
or are there really xHCI controllers with more than 31 USB 2.0 ports?
Should things be patched to support them properly?
Regards,
Michal
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: xhci: limit ports on the correct root hub
2026-06-04 6:51 ` Michal Pecio
@ 2026-06-04 7:11 ` raoxu
0 siblings, 0 replies; 3+ messages in thread
From: raoxu @ 2026-06-04 7:11 UTC (permalink / raw)
To: michal.pecio
Cc: gregkh, linux-kernel, linux-usb, mathias.nyman, niklas.neronin,
raoxu, rollkingzzc
On Thu, Jun 04, 2026 at 08:51:36AM +0200, Michal Pecio wrote:
> Previous patch for the same bug, Cc its author and bad commit author.
> https://lore.kernel.org/linux-usb/20260516033443.3646966-1-rollkingzzc@gmail.com/
>
> I'm not sure how people keep discovering this issue - only by review
> or are there really xHCI controllers with more than 31 USB 2.0 ports?
> Should things be patched to support them properly?
Thanks for pointing this out.
I missed Zhang's earlier patch. My patch was based on reviewing commit
9a7ad750a8fb ("usb: xhci: move roothub port limit validation").
Before that refactoring, the USB2 and USB3 root hub port limits were
applied to the corresponding root hub directly. After the validation was
moved into xhci_create_rhub_port_array(), the helper receives the root
hub being initialized, but the limit path still updates
xhci->usb3_rhub.num_ports unconditionally. That changes the original
logic when the helper is called for the USB2 root hub.
So this was found by code review of that refactoring, not from a real
controller with more than 31 USB 2.0 root hub ports.
Thanks,
Xu Rao
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-04 7:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-04 3:48 [PATCH] usb: xhci: limit ports on the correct root hub raoxu
2026-06-04 6:51 ` Michal Pecio
2026-06-04 7:11 ` raoxu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox