summaryrefslogtreecommitdiff
path: root/drivers/gpio/gpio-uclass.c
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2021-09-12 01:05:51 +0300
committerTom Rini <trini@konsulko.com>2021-10-05 15:50:15 +0300
commit390ccffe07c45a3ad584ee6199cc1e63d07981ee (patch)
tree9d9e5ffbda7d377e6ee1d9a8d3a5c75fe2490b78 /drivers/gpio/gpio-uclass.c
parentc5b68ef8af3c2f515c1f5b8d63a69359a85d753b (diff)
downloadu-boot-390ccffe07c45a3ad584ee6199cc1e63d07981ee.tar.xz
gpio: Verify validity of pin offsets when looking up names
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> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/gpio/gpio-uclass.c')
-rw-r--r--drivers/gpio/gpio-uclass.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index bb2f23241e..45a7f8def4 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -141,7 +141,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;
}
/*