From: Peng Fan <peng.fan@linux.dev>
To: Thomas Gleixner <tglx@kernel.org>, Radu Rendec <radu@rendec.net>,
Frank Li <Frank.Li@nxp.com>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Shengjiu Wang <shengjiu.wang@nxp.com>,
Marc Zyngier <maz@kernel.org>
Cc: linux-kernel@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
Peng Fan <peng.fan@nxp.com>
Subject: [PATCH v2 3/8] irqchip/imx-intmux: Fix probe error path
Date: Thu, 03 Dec 2026 17:29:15 +0800 [thread overview]
Message-ID: <20261203-imx-intmux-v2-3-a6db1eed3b5f@nxp.com> (raw)
In-Reply-To: <20261203-imx-intmux-v2-0-a6db1eed3b5f@nxp.com>
From: Peng Fan <peng.fan@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. Mask each parent interrupt and wait for a running
chained handler to finish before detaching it, so the rollback cannot
race with an in-flight imx_intmux_irq_handler().
Also enable the clock before touching runtime PM so that a clock
failure cannot leave runtime PM enabled with an unbalanced usage
counter, and propagate a pm_runtime_set_active() failure after
unwinding the usage count and clock reference.
Fixes: 2fbb13961e74 ("irqchip: Add NXP INTMUX interrupt multiplexer support")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/irqchip/irq-imx-intmux.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
index 3b4eb9bd6678..06cf75a93373 100644
--- a/drivers/irqchip/irq-imx-intmux.c
+++ b/drivers/irqchip/irq-imx-intmux.c
@@ -229,16 +229,21 @@ 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);
+ ret = pm_runtime_set_active(&pdev->dev);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to set runtime PM active: %d\n", ret);
+ pm_runtime_put_noidle(&pdev->dev);
+ goto err_disable_clk;
+ }
+ pm_runtime_enable(&pdev->dev);
+
for (i = 0; i < channum; i++) {
data->irqchip_data[i].chanidx = i;
@@ -256,6 +261,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;
@@ -279,6 +285,24 @@ static int imx_intmux_probe(struct platform_device *pdev)
return 0;
out:
+ while (i--) {
+ /*
+ * Mask the parent interrupt and wait for a handler that is
+ * already running to finish before its data and mappings are
+ * torn down.
+ */
+ disable_irq(data->irqchip_data[i].irq);
+ 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);
+err_disable_clk:
clk_disable_unprepare(data->ipg_clk);
return ret;
}
--
2.56.0
next prev parent reply other threads:[~2026-12-03 9:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 9:29 [PATCH v2 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
2026-12-03 9:29 ` [PATCH v2 1/8] irqchip/imx-intmux: Don't create parent mappings while counting channels Peng Fan
2026-12-03 9:29 ` [PATCH v2 2/8] irqchip/imx-intmux: Dispose IRQ mappings on remove Peng Fan
2026-12-03 9:29 ` Peng Fan [this message]
2026-12-03 9:29 ` [PATCH v2 4/8] irqchip/imx-intmux: Reject zero channel count Peng Fan
2026-12-03 9:29 ` [PATCH v2 5/8] irqchip/imx-intmux: Mark input interrupts as level-triggered Peng Fan
2026-12-03 9:29 ` [PATCH v2 6/8] irqchip/imx-intmux: Don't WARN on malformed interrupt specifiers Peng Fan
2026-12-03 9:29 ` [PATCH v2 7/8] irqchip/imx-intmux: Use devm_irq_domain_create_linear() Peng Fan
2026-12-03 9:29 ` [PATCH v2 8/8] irqchip/imx-intmux: Factor out imx_intmux_teardown_channel() Peng Fan
2026-12-03 14:14 ` [PATCH v2 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203-imx-intmux-v2-3-a6db1eed3b5f@nxp.com \
--to=peng.fan@linux.dev \
--cc=Frank.Li@nxp.com \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=peng.fan@nxp.com \
--cc=radu@rendec.net \
--cc=s.hauer@pengutronix.de \
--cc=shengjiu.wang@nxp.com \
--cc=tglx@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®