Skip to content

Commit caeeef8

Browse files
bmorkgregkh
authored andcommitted
net: cdc_ether: fix divide by 0 on bad descriptors
commit 2cb80187ba065d7decad7c6614e35e07aec8a974 upstream. 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: Ben Hutchings <ben.hutchings@codethink.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 46bdabb commit caeeef8

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/net/usb/cdc_ether.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
221221
goto bad_desc;
222222
}
223223

224-
if (header.usb_cdc_ether_desc) {
224+
if (header.usb_cdc_ether_desc && info->ether->wMaxSegmentSize) {
225225
dev->hard_mtu = le16_to_cpu(info->ether->wMaxSegmentSize);
226226
/* because of Zaurus, we may be ignoring the host
227227
* side link address we were given.

0 commit comments

Comments
 (0)