Re: [PATCHv2] gpio: mvebu: fix devres LIFO ordering between GPIO chip and IRQ domain
From: Rosen Penev
Date: Sun Jul 12 2026 - 17:23:02 EST
On Fri, Jul 10, 2026 at 12:33 PM Linus Walleij <linusw@xxxxxxxxxx> wrote:
>
> On Tue, Jul 7, 2026 at 1:22 AM Rosen Penev <rosenp@xxxxxxxxx> 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().
> >
> > 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")
> > Assisted-by: opencode:big-pickle
> > Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
>
> Nice work on this driver!
>
> Despite it's a pre-existing issue, if you have time (and already
> have the hardware set up and all) can you look into converting this
> driver to IRQCHIP_IMMUTABLE?
Not a simple task looks like. This thing generated
1 file changed, 105 insertions(+), 149 deletions(-)
which means heavy testing is needed. There's also a huge chance of
regressions as the driver touches multiple pieces of hardware. I have
388 and 3720 that can be tested.
>
> Yours,
> Linus Walleij