* [PATCH] usb: renesas_usbhs: avoid uninitialized variable use
@ 2015-05-22 11:06 Arnd Bergmann
2015-05-22 11:33 ` Yoshihiro Shimoda
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2015-05-22 11:06 UTC (permalink / raw)
To: linux-arm-kernel
After the renesas_usbhs driver is enabled in ARM multi_v7_defconfig,
we now get a new warning:
renesas_usbhs/mod.c: In function 'usbhs_interrupt':
renesas_usbhs/mod.c:246:7: warning: 'intenb1' may be used uninitialized in this function [-Wmaybe-uninitialized]
gcc correctly points to a problem here, for the case that the
device is in host mode, we use the intenb1 variable without
having assigned it first. The state->intsts1 has a similar
problem, but gcc cannot know that.
This avoids the problem by initializing both sides of the
comparison to zero when we don't read them from the respective
registers.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 88a25e02f3 ("usb: renesas_usbhs: Add access control for INTSTS1 and INTENB1 register")
diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c
index e5ce6e6d4f51..d4be5d594896 100644
--- a/drivers/usb/renesas_usbhs/mod.c
+++ b/drivers/usb/renesas_usbhs/mod.c
@@ -223,6 +223,8 @@ static int usbhs_status_get_each_irq(struct usbhs_priv *priv,
if (usbhs_mod_is_host(priv)) {
state->intsts1 = usbhs_read(priv, INTSTS1);
intenb1 = usbhs_read(priv, INTENB1);
+ } else {
+ state->intsts1 = intenb1 = 0;
}
/* mask */
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] usb: renesas_usbhs: avoid uninitialized variable use
2015-05-22 11:06 [PATCH] usb: renesas_usbhs: avoid uninitialized variable use Arnd Bergmann
@ 2015-05-22 11:33 ` Yoshihiro Shimoda
2015-05-25 0:53 ` Simon Horman
0 siblings, 1 reply; 3+ messages in thread
From: Yoshihiro Shimoda @ 2015-05-22 11:33 UTC (permalink / raw)
To: linux-arm-kernel
Hi Arnd,
> Sent: Friday, May 22, 2015 8:07 PM
>
> After the renesas_usbhs driver is enabled in ARM multi_v7_defconfig,
> we now get a new warning:
>
> renesas_usbhs/mod.c: In function 'usbhs_interrupt':
> renesas_usbhs/mod.c:246:7: warning: 'intenb1' may be used uninitialized in this function [-Wmaybe-uninitialized]
>
> gcc correctly points to a problem here, for the case that the
> device is in host mode, we use the intenb1 variable without
> having assigned it first. The state->intsts1 has a similar
> problem, but gcc cannot know that.
>
> This avoids the problem by initializing both sides of the
> comparison to zero when we don't read them from the respective
> registers.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 88a25e02f3 ("usb: renesas_usbhs: Add access control for INTSTS1 and INTENB1 register")
Thank you very much for the patch!
Acked-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
(I'm not sure why a toolchain I used (Linaro GCC 2014.11) doesn't show this warning...)
Best regards,
Yoshihiro Shimoda
> diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c
> index e5ce6e6d4f51..d4be5d594896 100644
> --- a/drivers/usb/renesas_usbhs/mod.c
> +++ b/drivers/usb/renesas_usbhs/mod.c
> @@ -223,6 +223,8 @@ static int usbhs_status_get_each_irq(struct usbhs_priv *priv,
> if (usbhs_mod_is_host(priv)) {
> state->intsts1 = usbhs_read(priv, INTSTS1);
> intenb1 = usbhs_read(priv, INTENB1);
> + } else {
> + state->intsts1 = intenb1 = 0;
> }
>
> /* mask */
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] usb: renesas_usbhs: avoid uninitialized variable use
2015-05-22 11:33 ` Yoshihiro Shimoda
@ 2015-05-25 0:53 ` Simon Horman
0 siblings, 0 replies; 3+ messages in thread
From: Simon Horman @ 2015-05-25 0:53 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, May 22, 2015 at 11:33:57AM +0000, Yoshihiro Shimoda wrote:
> Hi Arnd,
>
> > Sent: Friday, May 22, 2015 8:07 PM
> >
> > After the renesas_usbhs driver is enabled in ARM multi_v7_defconfig,
> > we now get a new warning:
> >
> > renesas_usbhs/mod.c: In function 'usbhs_interrupt':
> > renesas_usbhs/mod.c:246:7: warning: 'intenb1' may be used uninitialized in this function [-Wmaybe-uninitialized]
> >
> > gcc correctly points to a problem here, for the case that the
> > device is in host mode, we use the intenb1 variable without
> > having assigned it first. The state->intsts1 has a similar
> > problem, but gcc cannot know that.
> >
> > This avoids the problem by initializing both sides of the
> > comparison to zero when we don't read them from the respective
> > registers.
> >
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > Fixes: 88a25e02f3 ("usb: renesas_usbhs: Add access control for INTSTS1 and INTENB1 register")
>
> Thank you very much for the patch!
>
> Acked-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
>
> (I'm not sure why a toolchain I used (Linaro GCC 2014.11) doesn't show this warning...)
>
> Best regards,
> Yoshihiro Shimoda
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
>
> > diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c
> > index e5ce6e6d4f51..d4be5d594896 100644
> > --- a/drivers/usb/renesas_usbhs/mod.c
> > +++ b/drivers/usb/renesas_usbhs/mod.c
> > @@ -223,6 +223,8 @@ static int usbhs_status_get_each_irq(struct usbhs_priv *priv,
> > if (usbhs_mod_is_host(priv)) {
> > state->intsts1 = usbhs_read(priv, INTSTS1);
> > intenb1 = usbhs_read(priv, INTENB1);
> > + } else {
> > + state->intsts1 = intenb1 = 0;
> > }
> >
> > /* mask */
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> > the body of a message to majordomo at vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-05-25 0:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-22 11:06 [PATCH] usb: renesas_usbhs: avoid uninitialized variable use Arnd Bergmann
2015-05-22 11:33 ` Yoshihiro Shimoda
2015-05-25 0:53 ` Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).