Skip to content

Commit 397430b

Browse files
oneukumkuba-moo
authored andcommitted
usbnet: sanity check for maxpacket
maxpacket of 0 makes no sense and oopses as we need to divide by it. Give up. V2: fixed typo in log and stylistic issues Signed-off-by: Oliver Neukum <[email protected]> Reported-by: [email protected] Reviewed-by: Johan Hovold <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e378f49 commit 397430b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/net/usb/usbnet.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,10 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
17881788
if (!dev->rx_urb_size)
17891789
dev->rx_urb_size = dev->hard_mtu;
17901790
dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1);
1791+
if (dev->maxpacket == 0) {
1792+
/* that is a broken device */
1793+
goto out4;
1794+
}
17911795

17921796
/* let userspace know we have a random address */
17931797
if (ether_addr_equal(net->dev_addr, node_id))

0 commit comments

Comments
 (0)