* [PATCH] drivers/usb/host/imx21-hcd.c: fix divide-by-zero in func nonisoc_etd_done [not found] <1559564879-88739-1-git-send-email-duyanlin@huawei.com> @ 2019-06-05 2:02 ` Duyanlin 2019-06-05 9:48 ` gregkh 0 siblings, 1 reply; 2+ messages in thread From: Duyanlin @ 2019-06-05 2:02 UTC (permalink / raw) To: gregkh, shawnguo, s.hauer, kernel, festevam, linux-imx Cc: linux-usb, linux-arm-kernel, linux-kernel, Zengweilin If the function usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)) returns 0, that will cause a illegal divide-by-zero operation, unexpected results may occur. It is best to ensure that the denominator is non-zero before dividing by zero. Signed-off-by: Yanlin Du <duyanlin@huawei.com> --- drivers/usb/host/imx21-hcd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/imx21-hcd.c b/drivers/usb/host/imx21-hcd.c index 6e3dad1..6a47f78 100644 --- a/drivers/usb/host/imx21-hcd.c +++ b/drivers/usb/host/imx21-hcd.c @@ -1038,6 +1038,7 @@ static void nonisoc_etd_done(struct usb_hcd *hcd, int etd_num) int cc; u32 bytes_xfrd; int etd_done; + unsigned int maxp; disactivate_etd(imx21, etd_num); @@ -1104,13 +1105,13 @@ static void nonisoc_etd_done(struct usb_hcd *hcd, int etd_num) break; case PIPE_BULK: + maxp = usb_maxpacket(urb->dev, urb->pipe, + usb_pipeout(urb->pipe)); urb->actual_length += bytes_xfrd; if ((urb_priv->state == US_BULK) && (urb->transfer_flags & URB_ZERO_PACKET) && urb->transfer_buffer_length > 0 - && ((urb->transfer_buffer_length % - usb_maxpacket(urb->dev, urb->pipe, - usb_pipeout(urb->pipe))) == 0)) { + && maxp && (urb->transfer_buffer_length % maxp == 0)) { /* need a 0-packet */ urb_priv->state = US_BULK0; } else { -- 1.8.5.6 ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] drivers/usb/host/imx21-hcd.c: fix divide-by-zero in func nonisoc_etd_done 2019-06-05 2:02 ` [PATCH] drivers/usb/host/imx21-hcd.c: fix divide-by-zero in func nonisoc_etd_done Duyanlin @ 2019-06-05 9:48 ` gregkh 0 siblings, 0 replies; 2+ messages in thread From: gregkh @ 2019-06-05 9:48 UTC (permalink / raw) To: Duyanlin Cc: shawnguo, s.hauer, kernel, festevam, linux-imx, linux-usb, linux-arm-kernel, linux-kernel, Zengweilin On Wed, Jun 05, 2019 at 02:02:40AM +0000, Duyanlin wrote: > > If the function usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)) returns 0, that will cause a illegal divide-by-zero operation, unexpected results may occur. > It is best to ensure that the denominator is non-zero before dividing by zero. Please wrap your changelog comments at 72 columns. > Signed-off-by: Yanlin Du <duyanlin@huawei.com> This name HAS to match the From: line of your email. For that reason alone I can not take this patch. > --- > drivers/usb/host/imx21-hcd.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/usb/host/imx21-hcd.c b/drivers/usb/host/imx21-hcd.c index 6e3dad1..6a47f78 100644 > --- a/drivers/usb/host/imx21-hcd.c > +++ b/drivers/usb/host/imx21-hcd.c > @@ -1038,6 +1038,7 @@ static void nonisoc_etd_done(struct usb_hcd *hcd, int etd_num) > int cc; > u32 bytes_xfrd; > int etd_done; > + unsigned int maxp; > > disactivate_etd(imx21, etd_num); > > @@ -1104,13 +1105,13 @@ static void nonisoc_etd_done(struct usb_hcd *hcd, int etd_num) > break; > > case PIPE_BULK: > + maxp = usb_maxpacket(urb->dev, urb->pipe, > + usb_pipeout(urb->pipe)); How can this ever be 0? Don't we abort a lot earlier if a pipe length is 0? thanks, greg k-h ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-05 9:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1559564879-88739-1-git-send-email-duyanlin@huawei.com>
2019-06-05 2:02 ` [PATCH] drivers/usb/host/imx21-hcd.c: fix divide-by-zero in func nonisoc_etd_done Duyanlin
2019-06-05 9:48 ` gregkh
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®