Re: [PATCH 1/4] gpio: mt7621: avoid corruption of shared interrupt trigger state
From: Bartosz Golaszewski
Date: Mon Jun 22 2026 - 04:19:33 EST
On Sat, 20 Jun 2026 14:01:33 +0200, Sergio Paracuellos
<sergio.paracuellos@xxxxxxxxx> said:
> The bank-shared fields like 'rising' and 'falling' are modified using
> non-atomic read-modify-write operations. Since every gpio chip instance
> represents an entire bank of 32 pins, if 'mediatek_gpio_irq_type()' is
> called concurrently for different IRQs on the same bank a possible overwrite
> of each other's configuration is possible. Thus, protect this state with
> 'gpio_generic_lock_irqsave' lock in the same way it is handled in irp_chip
> 'mediatek_gpio_irq_mask()' and 'mediatek_gpio_irq_unmask()' callbacks.
>
> Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@xxxxxxxxx>
> ---
> drivers/gpio/gpio-mt7621.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpio/gpio-mt7621.c b/drivers/gpio/gpio-mt7621.c
> index a814885ccd5d..ceb99641baee 100644
> --- a/drivers/gpio/gpio-mt7621.c
> +++ b/drivers/gpio/gpio-mt7621.c
> @@ -187,6 +187,8 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int type)
> struct mtk_gc *rg = gpiochip_get_data(gc);
> u32 mask = BIT(mt7621_gpio_hwirq_to_offset(d->hwirq, rg));
>
> + guard(gpio_generic_lock_irqsave)(&rg->chip);
> +
> if (type == IRQ_TYPE_PROBE) {
> if ((rg->rising | rg->falling |
> rg->hlevel | rg->llevel) & mask)
> --
> 2.43.0
>
>
>
Can you add a Fixes: tag and Cc stable? I'll queue it for v7.2-rc1.
Bart