Skip to content

Commit 693ecbe

Browse files
oneukumgregkh
authored andcommitted
usbnet: sanity check for maxpacket
commit 397430b upstream. 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 <oneukum@suse.com> Reported-by: syzbot+76bb1d34ffa0adc03baa@syzkaller.appspotmail.com Reviewed-by: Johan Hovold <johan@kernel.org> Link: https://lore.kernel.org/r/20211021122944.21816-1-oneukum@suse.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b663890 commit 693ecbe

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎drivers/net/usb/usbnet.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,10 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
17551755
if (!dev->rx_urb_size)
17561756
dev->rx_urb_size = dev->hard_mtu;
17571757
dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1);
1758+
if (dev->maxpacket == 0) {
1759+
/* that is a broken device */
1760+
goto out4;
1761+
}
17581762

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

0 commit comments

Comments
 (0)