Re: [PATCH] gpiolib: initialize return value in gpiochip_set_multiple()
From: Uwe Kleine-König
Date: Sat Jun 20 2026 - 12:45:18 EST
On Sat, Jun 20, 2026 at 11:53:19PM +0800, Ruoyu Wang wrote:
> gpiochip_set_multiple() falls back to setting lines one by one when the
> chip does not provide set_multiple(). If the fallback path receives an
> empty mask, the loop is skipped and ret is returned without being
> initialized.
>
> Initialize ret to 0 so an empty mask is treated as a successful no-op.
>
> Fixes: 9b407312755f ("gpiolib: rework the wrapper around gpio_chip::set_multiple()")
> Signed-off-by: Ruoyu Wang <ruoyuw560@xxxxxxxxx>
> ---
> drivers/gpio/gpiolib.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 1e6dce430dca..cd2a619da456 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -3778,7 +3778,7 @@ static int gpiochip_set_multiple(struct gpio_chip *gc,
> unsigned long *mask, unsigned long *bits)
> {
> unsigned int i;
> - int ret;
> + int ret = 0;
>
> lockdep_assert_held(&gc->gpiodev->srcu);
While I think it's questionable to call gpiochip_set_multiple with an
empty mask, returning a random value isn't the right reaction.
Acked-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxx>
Did you find that by manual code inspection, or using a tool?
Best regards
Uwe
>
Attachment:
signature.asc
Description: PGP signature