Commit
38d44f78f041ffe60c8e2443b99434a199e7541d
gpio: mxc: fix race between chained IRQ handler install and probe completion
mxc_update_irq_chained_handler() is called before the IRQ domain, the
generic IRQ chip, and the port list entry are set up. If an interrupt
arrives in that window:
- mx3_gpio_irq_handler() calls generic_handle_domain_irq() with
port->domain still NULL.
- mx2_gpio_irq_handler() walks mxc_gpio_ports, but the port has not
been added to the list yet.
Additionally, if any of the subsequent probe steps
(gpio_generic_chip_init(), devm_gpiochip_add_data(),
irq_domain_create_legacy(), or mxc_gpio_init_gc()) fail, the error
paths never unregister the chained handler, leaving a dangling handler
that points at freed memory.
Move the handler installation after all its dependencies are ready and
after list_add_tail(), so the handler is never live while the data
structures it touches are incomplete, and is never installed if probe
fails.
Fixes: 5f6d1998adeb ("gpio: mxc: release the parent IRQ in runtime suspend")
Assisted-by: LLM
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://patch.msgid.link/20261013-gpio-mxc-cleanup-v7-1-c4d769587d3e@nxp.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Peng Fan <peng.fan@nxp.com> · 2026-10-13 06:01 UTC · committed by Bartosz Golaszewski
1 file changed,
+2
−2
modified drivers/gpio/gpio-mxc.c
| @@ -474,8 +474,6 @@ static int mxc_gpio_probe(struct platform_device *pdev) | |||
| 474 | 474 | } else | |
| 475 | 475 | port->mx_irq_handler = mx3_gpio_irq_handler; | |
| 476 | 476 | ||
| 477 | - | mxc_update_irq_chained_handler(port, true); | |
| 478 | - | ||
| 479 | 477 | config.dev = &pdev->dev; | |
| 480 | 478 | config.sz = 4; | |
| 481 | 479 | config.dat = port->base + GPIO_PSR; | |
| @@ -525,6 +523,8 @@ static int mxc_gpio_probe(struct platform_device *pdev) | |||
| 525 | 523 | ||
| 526 | 524 | list_add_tail(&port->node, &mxc_gpio_ports); | |
| 527 | 525 | ||
| 526 | + | mxc_update_irq_chained_handler(port, true); | |
| 527 | + | ||
| 528 | 528 | platform_set_drvdata(pdev, port); | |
| 529 | 529 | pm_runtime_put_autosuspend(&pdev->dev); | |
| 530 | 530 | ||