]> git.hungrycats.org Git - linux/commitdiff
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 Nov 2017 07:35:56 +0000 (08:35 +0100)
[ Upstream commit 2cb80187ba065d7decad7c6614e35e07aec8a974 ]

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/usb/cdc_ether.c

index 8ab281b478f23bd98d71b896a0c00c4fdba7dacc..4f88f64cccb49c24c579629676d19d8facd78e07 100644 (file)
@@ -221,7 +221,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.