[PATCH 1/8] irqchip/imx-intmux: Fix probe error path
Peng Fan
peng.fan at linux.dev
Mon Nov 16 23:14:05 PST 2026
From: Peng Fan <peng.fan at nxp.com>
When setting up a channel fails after previous channels have been
initialized, the error path only disables the clock. The chained
handlers of those channels stay registered with handler data pointing
into the devres-managed intmux_data, which is released when probe
fails, leaving dangling pointers behind. The created IRQ domains and
parent IRQ mappings are leaked as well.
Unwind the initialized channels, tear down runtime PM and only then
disable the clock. Also enable the clock before touching runtime PM so
that a clock failure cannot leave runtime PM enabled with an
unbalanced usage counter.
Fixes: 2fbb13961e74 ("irqchip: Add NXP INTMUX interrupt multiplexer support")
Signed-off-by: Peng Fan <peng.fan at nxp.com>
---
drivers/irqchip/irq-imx-intmux.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
index c7914fea3d1f..a9eda7646e2f 100644
--- a/drivers/irqchip/irq-imx-intmux.c
+++ b/drivers/irqchip/irq-imx-intmux.c
@@ -233,16 +233,16 @@ static int imx_intmux_probe(struct platform_device *pdev)
data->channum = channum;
raw_spin_lock_init(&data->lock);
- pm_runtime_get_noresume(&pdev->dev);
- pm_runtime_set_active(&pdev->dev);
- pm_runtime_enable(&pdev->dev);
-
ret = clk_prepare_enable(data->ipg_clk);
if (ret) {
dev_err(&pdev->dev, "failed to enable ipg clk: %d\n", ret);
return ret;
}
+ pm_runtime_get_noresume(&pdev->dev);
+ pm_runtime_set_active(&pdev->dev);
+ pm_runtime_enable(&pdev->dev);
+
for (i = 0; i < channum; i++) {
data->irqchip_data[i].chanidx = i;
@@ -258,6 +258,7 @@ static int imx_intmux_probe(struct platform_device *pdev)
if (!domain) {
ret = -ENOMEM;
dev_err(&pdev->dev, "failed to create IRQ domain\n");
+ irq_dispose_mapping(data->irqchip_data[i].irq);
goto out;
}
data->irqchip_data[i].domain = domain;
@@ -281,6 +282,17 @@ static int imx_intmux_probe(struct platform_device *pdev)
return 0;
out:
+ while (i--) {
+ irq_set_chained_handler_and_data(data->irqchip_data[i].irq,
+ NULL, NULL);
+ for (unsigned int hwirq = 0; hwirq < 32; hwirq++)
+ irq_dispose_mapping(irq_find_mapping(data->irqchip_data[i].domain,
+ hwirq));
+ irq_domain_remove(data->irqchip_data[i].domain);
+ irq_dispose_mapping(data->irqchip_data[i].irq);
+ }
+ pm_runtime_disable(&pdev->dev);
+ pm_runtime_put_noidle(&pdev->dev);
clk_disable_unprepare(data->ipg_clk);
return ret;
}
--
2.56.0
More information about the linux-arm-kernel
mailing list