usb:host: fix divide-by-zero in function fhci_queue_urb
Quoted 10 lines · Greg KH
Quoted 3 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 3 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 1 line
Signed-off-by zhuyan <[email protected]>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.
Then, in function fhci_queue_urb, the divisor of expression (urb->transfer_buffer_length % usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe))) is zero. It will lead to unpredictable results.
Thanks!
Yan Zhu
Quoted 13 lines · zhuyan (M)
Quoted 12 lines · Greg KH
Quoted 3 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 use urb->pipe to compute the maxpacket size anyway. It should use usb_endpoint_maxp(&urb->ep->desc).
Alan Stern
Quoted 3 lines
Then, in function
fhci_queue_urb, the divisor of expression (urb->transfer_buffer_length%usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe))) is zero. It will lead to unpredictable results.