From: Bjørn Mork Date: Mon, 6 Nov 2017 14:37:22 +0000 (+0100) Subject: net: cdc_ether: fix divide by 0 on bad descriptors X-Git-Tag: archive/raspbian/4.15.4-1+rpi1~1^2^2^2~22 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=8ee6e749253d24d414c556979d563cbca45928a6;p=linux.git 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 Acked-by: Oliver Neukum Signed-off-by: David S. Miller Gbp-Pq: Topic bugfix/all Gbp-Pq: Name net-cdc_ether-fix-divide-by-0-on-bad-descriptors.patch --- diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index 8ab281b478f..4f88f64cccb 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c @@ -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.