Re: [PATCHv2] gpio: mvebu: fix devres LIFO ordering between GPIO chip and IRQ domain

From: Rosen Penev

Date: Tue Jul 07 2026 - 20:18:58 EST


On Tue, Jul 7, 2026 at 12:13 AM Uwe Kleine-König
<u.kleine-koenig@xxxxxxxxxxxx> wrote:
>
> On Mon, Jul 06, 2026 at 04:22:23PM -0700, Rosen Penev wrote:
> > During driver removal, devres cleans up in LIFO order. The IRQ domain
> > was created and its devm cleanup action registered after
> > devm_gpiochip_add_data(), so the domain was destroyed before the GPIO
> > chip was deregistered. If gpiod_to_irq() is called on a pin during
> > this window, mvebu_gpio_to_irq() passes the freed mvchip->domain to
> > irq_create_mapping().
>
> Without having looked at your patch, I would expect that there is a
> similar window during probe where calling gpiod_to_irq() between
> devm_gpiochip_add_data() and IRQ domain creation results in an invalid
> mvchip->domain being passed to irq_create_mapping(), right?
This patch fixes that.
>
> > Fix by moving the IRQ domain creation, devm cleanup action registration,
> > generic chip allocation, and chip type setup before
> > devm_gpiochip_add_data(). This ensures the GPIO chip is torn down
> > first (preventing new IRQ mappings), then the IRQ domain is removed,
> > and finally mvchip is freed.
> >
> > Fixes: 644ee70267a9 ("gpio: mvebu: fix irq domain leak")
>
> If the above is right, the referenced commit only creates the issue at
> driver detach. The issue at probe time exists since
> fefe7b092345 ("gpio: introduce gpio-mvebu driver for Marvell SoCs")
> which has `gpiochip_add(&mvchip->chip);` before coping for irqs.
Will fix.
>
> Best regards
> Uwe