]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
USB: hub: fix SS max number of ports
authorJohan Hovold <johan@kernel.org>
Wed, 10 May 2017 16:18:29 +0000 (18:18 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 May 2017 09:53:02 +0000 (11:53 +0200)
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: dbe79bbe9dcb ("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>
drivers/usb/core/hub.c
include/uapi/linux/usb/ch11.h

index f77a4ebde7d576e9f0fa8a71a13650cd0873dc99..b8bb20d7acdb9f1480009605f10e2f5ae4045ec9 100644 (file)
@@ -1336,7 +1336,13 @@ static int hub_configure(struct usb_hub *hub,
        if (ret < 0) {
                message = "can't read hub descriptor";
                goto fail;
-       } else if (hub->descriptor->bNbrPorts > USB_MAXCHILDREN) {
+       }
+
+       maxchild = USB_MAXCHILDREN;
+       if (hub_is_superspeed(hdev))
+               maxchild = min_t(unsigned, maxchild, USB_SS_MAXPORTS);
+
+       if (hub->descriptor->bNbrPorts > maxchild) {
                message = "hub has too many ports!";
                ret = -ENODEV;
                goto fail;
index 361297e96f5826360bb24f80de9089b83a9881ba..576c704e3fb8b13f358ae67b3a415417f2c37cb5 100644 (file)
@@ -22,6 +22,9 @@
  */
 #define USB_MAXCHILDREN                31
 
+/* See USB 3.1 spec Table 10-5 */
+#define USB_SS_MAXPORTS                15
+
 /*
  * Hub request types
  */