usbnet: ignore endpoints with invalid wMaxPacketSize
authorBjørn Mork <bjorn@mork.no>
Wed, 18 Sep 2019 12:17:38 +0000 (14:17 +0200)
committerJakub Kicinski <jakub.kicinski@netronome.com>
Sat, 21 Sep 2019 19:06:55 +0000 (12:06 -0700)
Endpoints with zero wMaxPacketSize are not usable for transferring
data. Ignore such endpoints when looking for valid in, out and
status pipes, to make the drivers more robust against invalid and
meaningless descriptors.

The wMaxPacketSize of these endpoints are used for memory allocations
and as divisors in many usbnet minidrivers. Avoiding zero is therefore
critical.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
drivers/net/usb/usbnet.c

index e44849499b89e21384b07ef4759ed6b1f5c29d15..dde05e2fdc3e6325431f079d04db8fc898be4a67 100644 (file)
@@ -100,6 +100,11 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
                        int                             intr = 0;
 
                        e = alt->endpoint + ep;
+
+                       /* ignore endpoints which cannot transfer data */
+                       if (!usb_endpoint_maxp(&e->desc))
+                               continue;
+
                        switch (e->desc.bmAttributes) {
                        case USB_ENDPOINT_XFER_INT:
                                if (!usb_endpoint_dir_in(&e->desc))