Re: [PATCH v2 1/5] gpiolib: don't overwrite the entire flags field in gpiod_get_direction()
From: Linus Walleij
Date: Tue Nov 17 2026 - 09:05:06 EST
On Mon, Nov 9, 2026 at 11:27 AM Bartosz Golaszewski
<bartosz.golaszewski@xxxxxxxxxxxxxxxx> wrote:
> gpiod_get_direction() snapshots desc->flags with READ_ONCE(), updates
> FLAG_IS_OUT in the local copy and writes the whole word back with
> WRITE_ONCE(). Any bit that a concurrent user sets or clears atomically in
> between - for instance: FLAG_USED_AS_IRQ from gpiochip_lock_as_irq() - is
> silently lost.
>
> Update FLAG_IS_OUT with a single atomic assign_bit() directly on
> desc->flags. The earlier READ_ONCE() snapshot is only used for the
> open-drain check and stays.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: 2559f2e09211 ("gpio: reinforce desc->flags handling")
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>
Yours,
Linus Walleij