Skip to content

Commit

Permalink
cdc_ncm: fix divide-by-zero caused by invalid wMaxPacketSize
Browse files Browse the repository at this point in the history
Endpoints with zero wMaxPacketSize are not usable for transferring
data. Ignore such endpoints when looking for valid in, out and
status pipes, to make the driver more robust against invalid and
meaningless descriptors.

The wMaxPacketSize of the out pipe is used as divisor. So this change
fixes a divide-by-zero bug.

Reported-by: [email protected]
Signed-off-by: Bjørn Mork <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
bmork authored and Jakub Kicinski committed Sep 21, 2019
1 parent 7b09c2d commit 3fe4b33
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/net/usb/cdc_ncm.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,12 @@ cdc_ncm_find_endpoints(struct usbnet *dev, struct usb_interface *intf)
u8 ep;

for (ep = 0; ep < intf->cur_altsetting->desc.bNumEndpoints; ep++) {

e = intf->cur_altsetting->endpoint + ep;

/* ignore endpoints which cannot transfer data */
if (!usb_endpoint_maxp(&e->desc))
continue;

switch (e->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
case USB_ENDPOINT_XFER_INT:
if (usb_endpoint_dir_in(&e->desc)) {
Expand Down

0 comments on commit 3fe4b33

Please sign in to comment.