usb:host: fix divide-by-zero in function fhci_queue_urb
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.
Signed-off-by zhuyan <[email protected]>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 useurb->pipeto compute the maxpacket size anyway. It should useusb_endpoint_maxp(&urb->ep->desc).
Quoted 6 lines
Quoted 3 lines
Currently,
fhci_queue_urb(), callusb_maxpacket()multiple times to calculate the maxpacket size. Theusb_maxpacket()will callusb_endpoint_maxp()to compute the maxpacket size.I know that. What
fhci_queue_urb()is doing is wrong. You should change
it: Make it callusb_endpoint_maxpdirectly instead of callingusb_maxpacket.
ok, I will resubmit a patch to repair it.
Best wish to you!
zhuyan