linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: trix@redhat.com
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	Frank Rowand <frank.rowand@sony.com>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] gpiolib: of: reset name variable in of_gpiochip_add_hog
Date: Wed, 5 Aug 2020 16:04:28 +0200	[thread overview]
Message-ID: <CAMuHMdX-m+q-SYveM2BQyM+EoiQ1ctVviJzjs+UbTzH9cJaqMQ@mail.gmail.com> (raw)
In-Reply-To: <20200728134226.27592-1-trix@redhat.com>

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

      parent reply	other threads:[~2020-08-05 16:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=CAMuHMdX-m+q-SYveM2BQyM+EoiQ1ctVviJzjs+UbTzH9cJaqMQ@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=bgolaszewski@baylibre.com \
    --cc=frank.rowand@sony.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=trix@redhat.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;
as well as URLs for NNTP newsgroup(s).