Skip to contentSkip to conversation

usb:host: fix divide-by-zero in function fhci_queue_urb

PATCH zhuyan (M) 1 participant 1 message Apr 17, 2019 USB

lore
Share & tools
lore

zhuyan (M)

author
#0 lore raw
Quoted 28 lines · Alan Stern
Quoted 27 lines · zhuyan (M)
Quoted 25 lines · Alan Stern
Quoted 14 lines · zhuyan (M)
Quoted 13 lines · Greg KH
Quoted 4 lines · zhuyan

In function fhci_queue_urb, the divisor of expression (urb->transfer_buffer_length % usb_maxpacket(urb->dev, urb->pipe,
usb_pipeout(urb->pipe))) may be zero.

How can you hit that?

Quoted 4 lines

When it is zero, unexpected results may occur, so it is necessary to ensure that the divisor is not zero.

Quoted 7 lines
Quoted 5 lines

I need a "Full" name here, not just a single name. Whatever you use to sign documents is good.

thanks,

greg k-h

In function usb_maxpacket, when ep is NULL, its return value is 0.

fhci_queue_urb() shouldn't use urb->pipe to compute the maxpacket size anyway. It should use usb_endpoint_maxp(&urb->ep->desc).

Quoted 6 lines
Quoted 3 lines

Currently, fhci_queue_urb(), call usb_maxpacket() multiple times to calculate the maxpacket size. The usb_maxpacket() will call usb_endpoint_maxp() to compute the maxpacket size.

I know that. What fhci_queue_urb() is doing is wrong. You should change
it: Make it call usb_endpoint_maxp directly instead of calling usb_maxpacket.

ok, I will resubmit a patch to repair it.

Best wish to you!
zhuyan