net: cdc_ether: fix divide by 0 on bad descriptors
authorBjørn Mork <bjorn@mork.no>
Mon, 6 Nov 2017 14:37:22 +0000 (15:37 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 8 Nov 2017 04:42:01 +0000 (13:42 +0900)
Setting dev->hard_mtu to 0 will cause a divide error in
usbnet_probe. Protect against devices with bogus CDC Ethernet
functional descriptors by ignoring a zero wMaxSegmentSize.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
Acked-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/cdc_ether.c

index 3e7a3ac3a36236054b897bc7beda770a765a95e5..05dca3e5c93d4baf7fb975a6fef30d3d322f1aaf 100644 (file)
@@ -230,7 +230,7 @@ skip:
                        goto bad_desc;
        }
 
-       if (header.usb_cdc_ether_desc) {
+       if (header.usb_cdc_ether_desc && info->ether->wMaxSegmentSize) {
                dev->hard_mtu = le16_to_cpu(info->ether->wMaxSegmentSize);
                /* because of Zaurus, we may be ignoring the host
                 * side link address we were given.