From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Johannes Thumshirn <morbidrsa@gmail.com>
Cc: Alan Stern <stern@rowland.harvard.edu>,
Sarah Sharp <sarah.a.sharp@linux.intel.com>,
Lan Tianyu <tianyu.lan@intel.com>,
Xenia Ragiadakou <burzalodowa@gmail.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: hub: avoid possible division by zero
Date: Sat, 23 Nov 2013 09:20:10 -0800 [thread overview]
Message-ID: <20131123172010.GA8018@kroah.com> (raw)
In-Reply-To: <1385224294-15461-1-git-send-email-morbidrsa@gmail.com>
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
next prev parent reply other threads:[~2013-11-23 17:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-23 16:31 [PATCH] usb: hub: avoid possible division by zero Johannes Thumshirn
2013-11-23 17:20 ` Greg Kroah-Hartman [this message]
2013-11-23 17:26 ` Johannes Thumshirn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131123172010.GA8018@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=burzalodowa@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=morbidrsa@gmail.com \
--cc=sarah.a.sharp@linux.intel.com \
--cc=stern@rowland.harvard.edu \
--cc=tianyu.lan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox