All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Holland <samuel@sholland.org>
To: u-boot@lists.denx.de
Cc: Samuel Holland <samuel@sholland.org>,
	Dario Binacchi <dariobin@libero.it>,
	Jean-Jacques Hiblot <jjhiblot@ti.com>,
	Patrick Delaunay <patrick.delaunay@foss.st.com>,
	Pratyush Yadav <p.yadav@ti.com>, Simon Glass <sjg@chromium.org>
Subject: [PATCH 1/3] gpio: Verify validity of pin offsets when looking up names
Date: Sat, 11 Sep 2021 17:05:51 -0500	[thread overview]
Message-ID: <20210911220553.9427-2-samuel@sholland.org> (raw)
In-Reply-To: <20210911220553.9427-1-samuel@sholland.org>

Translation of a pin name to a device+offset should fail if the offset
is larger than the number of pins in the GPIO bank.

Signed-off-by: Samuel Holland <samuel@sholland.org>
---

 drivers/gpio/gpio-uclass.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 8c77777dbe3..57e87960ee4 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -140,7 +140,8 @@ int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc)
 
 		if (!strncasecmp(name, uc_priv->bank_name, len)) {
 			if (!strict_strtoul(name + len, 10, &offset))
-				break;
+				if (offset < uc_priv->gpio_count)
+					break;
 		}
 
 		/*
-- 
2.31.1


  reply	other threads:[~2021-09-11 22:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-11 22:05 [PATCH 0/3] gpio: uclass enhancements for DM_GPIO drivers Samuel Holland
2021-09-11 22:05 ` Samuel Holland [this message]
2021-09-30  4:08   ` [PATCH 1/3] gpio: Verify validity of pin offsets when looking up names Simon Glass
2021-10-05 22:02   ` Tom Rini
2021-09-11 22:05 ` [PATCH 2/3] gpio: Verify validity of pin offsets from device trees Samuel Holland
2021-09-30  4:08   ` Simon Glass
2021-10-05 22:02   ` Tom Rini
2021-10-05 22:02   ` Tom Rini
2021-09-11 22:05 ` [PATCH 3/3] gpio: Factor out DT flag translation Samuel Holland
2021-09-30  4:08   ` Simon Glass
2021-10-05 22:02   ` Tom Rini

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=20210911220553.9427-2-samuel@sholland.org \
    --to=samuel@sholland.org \
    --cc=dariobin@libero.it \
    --cc=jjhiblot@ti.com \
    --cc=p.yadav@ti.com \
    --cc=patrick.delaunay@foss.st.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.