lkml.org 
[lkml]   [2019]   [Apr]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] usb:host: fix divide-by-zero in function fhci_queue_urb
On Tue, 16 Apr 2019, zhuyan (M) wrote:

> On Tue, 16 Apr 2019 at 11:45:45 +0200, Greg KH wrote:
> > On Tue, Apr 09, 2019 at 10:37:12PM +0800, zhuyan wrote:
> > > 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?
> >
> > > When it is zero, unexpected results may occur, so it is necessary to
> > > ensure that the divisor is not zero.
> > >
> > > Signed-off-by: zhuyan <zhuyan34@huawei.com>
> >
> > 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

> 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.

\
 
 \ /
  Last update: 2019-04-16 17:08    [W:0.035 / U:2.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site