]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
gpio: Verify validity of pin offsets when looking up names
authorSamuel Holland <samuel@sholland.org>
Sat, 11 Sep 2021 22:05:51 +0000 (17:05 -0500)
committerTom Rini <trini@konsulko.com>
Tue, 5 Oct 2021 12:50:15 +0000 (08:50 -0400)
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>
drivers/gpio/gpio-uclass.c

index bb2f23241edba54f6baddc051c6ad14ee9cf09e5..45a7f8def4fb14a6056ed698a5932ec55b6c1d38 100644 (file)
@@ -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;
                }
 
                /*