[PATCH] gpio-uclass: fix off-by-one in gpio_request_list_by_name_nodev()
Simon Glass
sjg at chromium.org
Thu Apr 20 00:40:06 CEST 2023
On Wed, 19 Apr 2023 at 22:11, Rasmus Villemoes
<rasmus.villemoes at prevas.dk> wrote:
>
> By the time we jump to the err label, count represents the number of
> gpios we've succesfully requested. So by subtracting one, we fail to
> free the most recently requested.
>
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes at prevas.dk>
> ---
> drivers/gpio/gpio-uclass.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Simon Glass <sjg at chromium.org>
Could the tests catch this bug?
>
> diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
> index c8be5a4d66..712119c341 100644
> --- a/drivers/gpio/gpio-uclass.c
> +++ b/drivers/gpio/gpio-uclass.c
> @@ -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;
> }
> --
> 2.37.2
>
More information about the U-Boot
mailing list