* [PATCH] gpiolib: of: reset name variable in of_gpiochip_add_hog
@ 2020-07-28 13:42 trix
2020-07-28 18:27 ` Andy Shevchenko
2020-08-05 14:04 ` Geert Uytterhoeven
0 siblings, 2 replies; 3+ messages in thread
From: trix @ 2020-07-28 13:42 UTC (permalink / raw)
To: linus.walleij, bgolaszewski, frank.rowand, geert+renesas
Cc: linux-gpio, linux-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
Clang static analysis reports this error
gpiolib-of.c:664:9: warning: 2nd function call argument
is an uninitialized value [core.CallAndMessage]
ret = gpiod_hog(desc, name, lflags, dflags);
name is sometimes set by of_parse_own_gpio
name is always used by gpiod_hog
So it is necessary to reset name so an old value is
not mistakenly used by gpiod_hog.
Fixes: bc21077e084b ("gpio: of: Extract of_gpiochip_add_hog()")
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/gpio/gpiolib-of.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index bd31dd3b6a75..277ada41d04a 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -657,6 +657,7 @@ static int of_gpiochip_add_hog(struct gpio_chip *chip, struct device_node *hog)
int ret;
for (i = 0;; i++) {
+ name = NULL;
desc = of_parse_own_gpio(hog, chip, i, &name, &lflags, &dflags);
if (IS_ERR(desc))
break;
--
2.18.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] gpiolib: of: reset name variable in of_gpiochip_add_hog
2020-07-28 13:42 [PATCH] gpiolib: of: reset name variable in of_gpiochip_add_hog trix
@ 2020-07-28 18:27 ` Andy Shevchenko
2020-08-05 14:04 ` Geert Uytterhoeven
1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2020-07-28 18:27 UTC (permalink / raw)
To: trix
Cc: Linus Walleij, Bartosz Golaszewski, frank.rowand,
Geert Uytterhoeven, open list:GPIO SUBSYSTEM,
Linux Kernel Mailing List
On Tue, Jul 28, 2020 at 4:44 PM <trix@redhat.com> wrote:
>
> From: Tom Rix <trix@redhat.com>
>
> Clang static analysis reports this error
>
> gpiolib-of.c:664:9: warning: 2nd function call argument
> is an uninitialized value [core.CallAndMessage]
> ret = gpiod_hog(desc, name, lflags, dflags);
>
> name is sometimes set by of_parse_own_gpio
> name is always used by gpiod_hog
It's not clear if it's the output of the analyser.
If so, try to file a bug and fix there how it prints out functions,
should be func().
Otherwise fix in the commit message.
> So it is necessary to reset name so an old value is
the name
> not mistakenly used by gpiod_hog.
gpiod_hog()
> Fixes: bc21077e084b ("gpio: of: Extract of_gpiochip_add_hog()")
>
> Signed-off-by: Tom Rix <trix@redhat.com>
Should be no blank line in between.
> ---
> drivers/gpio/gpiolib-of.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
> index bd31dd3b6a75..277ada41d04a 100644
> --- a/drivers/gpio/gpiolib-of.c
> +++ b/drivers/gpio/gpiolib-of.c
> @@ -657,6 +657,7 @@ static int of_gpiochip_add_hog(struct gpio_chip *chip, struct device_node *hog)
> int ret;
>
> for (i = 0;; i++) {
> + name = NULL;
> desc = of_parse_own_gpio(hog, chip, i, &name, &lflags, &dflags);
> if (IS_ERR(desc))
> break;
> --
> 2.18.1
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gpiolib: of: reset name variable in of_gpiochip_add_hog
2020-07-28 13:42 [PATCH] gpiolib: of: reset name variable in of_gpiochip_add_hog trix
2020-07-28 18:27 ` Andy Shevchenko
@ 2020-08-05 14:04 ` Geert Uytterhoeven
1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2020-08-05 14:04 UTC (permalink / raw)
To: trix
Cc: Linus Walleij, Bartosz Golaszewski, Frank Rowand,
open list:GPIO SUBSYSTEM, Linux Kernel Mailing List
Hi Tom,
Thanks for your patch!
On Tue, Jul 28, 2020 at 3:42 PM <trix@redhat.com> wrote:
> From: Tom Rix <trix@redhat.com>
>
> Clang static analysis reports this error
>
> gpiolib-of.c:664:9: warning: 2nd function call argument
> is an uninitialized value [core.CallAndMessage]
> ret = gpiod_hog(desc, name, lflags, dflags);
>
> name is sometimes set by of_parse_own_gpio
> name is always used by gpiod_hog
This is a false-positive: gpiod_hog() is only called if
of_parse_own_gpio() returned success, in which case it has filled in the
name output parameter.
> So it is necessary to reset name so an old value is
> not mistakenly used by gpiod_hog.
Hence this is not needed.
> Fixes: bc21077e084b ("gpio: of: Extract of_gpiochip_add_hog()")
This is not the commit that introduced the "bug".
> Signed-off-by: Tom Rix <trix@redhat.com>
> --- a/drivers/gpio/gpiolib-of.c
> +++ b/drivers/gpio/gpiolib-of.c
> @@ -657,6 +657,7 @@ static int of_gpiochip_add_hog(struct gpio_chip *chip, struct device_node *hog)
> int ret;
>
> for (i = 0;; i++) {
> + name = NULL;
> desc = of_parse_own_gpio(hog, chip, i, &name, &lflags, &dflags);
> if (IS_ERR(desc))
> break;
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-05 16:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-28 13:42 [PATCH] gpiolib: of: reset name variable in of_gpiochip_add_hog trix
2020-07-28 18:27 ` Andy Shevchenko
2020-08-05 14:04 ` Geert Uytterhoeven
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).