summaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2017-11-06 15:37:22 +0100
committerDavid S. Miller <davem@davemloft.net>2017-11-08 13:42:01 +0900
commit2cb80187ba065d7decad7c6614e35e07aec8a974 (patch)
tree5eaea6c250d176f2b2f04cf13a6708f6b495c7d4 /drivers/net
parentb5f862180d7011d9575d0499fa37f0f25b423b12 (diff)
downloadlinux-2cb80187ba065d7decad7c6614e35e07aec8a974.tar.gz
linux-2cb80187ba065d7decad7c6614e35e07aec8a974.tar.bz2
linux-2cb80187ba065d7decad7c6614e35e07aec8a974.zip
net: cdc_ether: fix divide by 0 on bad descriptors
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>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/usb/cdc_ether.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 3e7a3ac3a362..05dca3e5c93d 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -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.