]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
gpio-uclass: fix off-by-one in gpio_request_list_by_name_nodev()
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>
Wed, 19 Apr 2023 10:10:13 +0000 (12:10 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 25 Apr 2023 19:31:28 +0000 (15:31 -0400)
By the time we jump to the err label, count represents the number of
gpios we've successfully requested. So by subtracting one, we fail to
free the most recently requested.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/gpio/gpio-uclass.c

index c8be5a4d668a78e180abb2679a451f332db3c448..712119c3415b8fb9bbf410d4da30ae07bdf3095a 100644 (file)
@@ -1219,7 +1219,7 @@ int gpio_request_list_by_name_nodev(ofnode node, const char *list_name,
        return count;
 
 err:
-       gpio_free_list_nodev(desc, count - 1);
+       gpio_free_list_nodev(desc, count);
 
        return ret;
 }