Linux-GPIO Archive on lore.kernel.org
 help / color / Atom feed
From: trix@redhat.com
To: linus.walleij@linaro.org, bgolaszewski@baylibre.com,
	frank.rowand@sony.com, geert+renesas@glider.be
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Tom Rix <trix@redhat.com>
Subject: [PATCH] gpiolib: of: reset name variable in of_gpiochip_add_hog
Date: Tue, 28 Jul 2020 06:42:26 -0700
Message-ID: <20200728134226.27592-1-trix@redhat.com> (raw)

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


             reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-28 13:42 trix [this message]
2020-07-28 18:27 ` Andy Shevchenko
2020-08-05 14:04 ` Geert Uytterhoeven

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=20200728134226.27592-1-trix@redhat.com \
    --to=trix@redhat.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=frank.rowand@sony.com \
    --cc=geert+renesas@glider.be \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

Linux-GPIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-gpio/0 linux-gpio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-gpio linux-gpio/ https://lore.kernel.org/linux-gpio \
		linux-gpio@vger.kernel.org
	public-inbox-index linux-gpio

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-gpio


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git