* [PATCH] usb: hub: avoid possible division by zero
@ 2013-11-23 16:31 Johannes Thumshirn
2013-11-23 17:20 ` Greg Kroah-Hartman
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Thumshirn @ 2013-11-23 16:31 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Alan Stern, Sarah Sharp, Lan Tianyu, Xenia Ragiadakou, linux-usb,
linux-kernel, Johannes Thumshirn
Avoid possible division by zero in led_work, if hdev->maxchild is 0.
See also:
http://buildbot.llvm.linuxfoundation.org/checker/scan-build-latest/report-b65939.html#EndPath
Signed-off-by: Johannes Thumshirn <morbidrsa@gmail.com>
---
drivers/usb/core/hub.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index a7c04e2..8c7aa4e 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -453,7 +453,8 @@ static void led_work (struct work_struct *work)
unsigned changed = 0;
int cursor = -1;
- if (hdev->state != USB_STATE_CONFIGURED || hub->quiescing)
+ if (hdev->state != USB_STATE_CONFIGURED || hub->quiescing
+ || hdev->maxchild == 0)
return;
for (i = 0; i < hdev->maxchild; i++) {
--
1.8.4.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: hub: avoid possible division by zero
2013-11-23 16:31 [PATCH] usb: hub: avoid possible division by zero Johannes Thumshirn
@ 2013-11-23 17:20 ` Greg Kroah-Hartman
2013-11-23 17:26 ` Johannes Thumshirn
0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2013-11-23 17:20 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: Alan Stern, Sarah Sharp, Lan Tianyu, Xenia Ragiadakou, linux-usb,
linux-kernel
On Sat, Nov 23, 2013 at 05:31:34PM +0100, Johannes Thumshirn wrote:
> Avoid possible division by zero in led_work, if hdev->maxchild is 0.
>
> See also:
> http://buildbot.llvm.linuxfoundation.org/checker/scan-build-latest/report-b65939.html#EndPath
>
> Signed-off-by: Johannes Thumshirn <morbidrsa@gmail.com>
> ---
> drivers/usb/core/hub.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index a7c04e2..8c7aa4e 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -453,7 +453,8 @@ static void led_work (struct work_struct *work)
> unsigned changed = 0;
> int cursor = -1;
>
> - if (hdev->state != USB_STATE_CONFIGURED || hub->quiescing)
> + if (hdev->state != USB_STATE_CONFIGURED || hub->quiescing
> + || hdev->maxchild == 0)
And how can maxchild ever be equal to 0?
Look at where it is assigned (it comes from bNbrPorts in the
descriptor), in hub_configure() and if it is set to 0, the creation of
the structure fails and then this code will never run, right?
So I don't think this is needed, and your checker needs to be fixed.
sorry,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: hub: avoid possible division by zero
2013-11-23 17:20 ` Greg Kroah-Hartman
@ 2013-11-23 17:26 ` Johannes Thumshirn
0 siblings, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2013-11-23 17:26 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Alan Stern, Sarah Sharp, Lan Tianyu, Xenia Ragiadakou, linux-usb,
linux-kernel
On Sat, Nov 23, 2013 at 09:20:10AM -0800, Greg Kroah-Hartman wrote:
> On Sat, Nov 23, 2013 at 05:31:34PM +0100, Johannes Thumshirn wrote:
> > Avoid possible division by zero in led_work, if hdev->maxchild is 0.
> >
> > See also:
> > http://buildbot.llvm.linuxfoundation.org/checker/scan-build-latest/report-b65939.html#EndPath
> >
> > Signed-off-by: Johannes Thumshirn <morbidrsa@gmail.com>
> > ---
> > drivers/usb/core/hub.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> > index a7c04e2..8c7aa4e 100644
> > --- a/drivers/usb/core/hub.c
> > +++ b/drivers/usb/core/hub.c
> > @@ -453,7 +453,8 @@ static void led_work (struct work_struct *work)
> > unsigned changed = 0;
> > int cursor = -1;
> >
> > - if (hdev->state != USB_STATE_CONFIGURED || hub->quiescing)
> > + if (hdev->state != USB_STATE_CONFIGURED || hub->quiescing
> > + || hdev->maxchild == 0)
>
> And how can maxchild ever be equal to 0?
>
> Look at where it is assigned (it comes from bNbrPorts in the
> descriptor), in hub_configure() and if it is set to 0, the creation of
> the structure fails and then this code will never run, right?
>
> So I don't think this is needed, and your checker needs to be fixed.
>
> sorry,
Args, sorry for the noise. Should've checked that better.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-11-23 17:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-23 16:31 [PATCH] usb: hub: avoid possible division by zero Johannes Thumshirn
2013-11-23 17:20 ` Greg Kroah-Hartman
2013-11-23 17:26 ` Johannes Thumshirn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox