Skip to content

Commit ec443ee

Browse files
jhovoldgregkh
authored andcommitted
USB: hub: fix SS max number of ports
commit 93491ced3c87c94b12220dbac0527e1356702179 upstream. Add define for the maximum number of ports on a SuperSpeed hub as per USB 3.1 spec Table 10-5, and use it when verifying the retrieved hub descriptor. This specifically avoids benign attempts to update the DeviceRemovable mask for non-existing ports (should we get that far). Fixes: dbe79bb ("USB 3.0 Hub Changes") Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7e2ad8b commit ec443ee

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

drivers/usb/core/hub.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,13 @@ static int hub_configure(struct usb_hub *hub,
13181318
if (ret < 0) {
13191319
message = "can't read hub descriptor";
13201320
goto fail;
1321-
} else if (hub->descriptor->bNbrPorts > USB_MAXCHILDREN) {
1321+
}
1322+
1323+
maxchild = USB_MAXCHILDREN;
1324+
if (hub_is_superspeed(hdev))
1325+
maxchild = min_t(unsigned, maxchild, USB_SS_MAXPORTS);
1326+
1327+
if (hub->descriptor->bNbrPorts > maxchild) {
13221328
message = "hub has too many ports!";
13231329
ret = -ENODEV;
13241330
goto fail;

include/uapi/linux/usb/ch11.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
*/
2323
#define USB_MAXCHILDREN 31
2424

25+
/* See USB 3.1 spec Table 10-5 */
26+
#define USB_SS_MAXPORTS 15
27+
2528
/*
2629
* Hub request types
2730
*/

0 commit comments

Comments
 (0)