mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Peng Fan" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Peng Fan <peng.fan@nxp.com>, Thomas Gleixner <tglx@kernel.org>,
	Frank Li <Frank.Li@nxp.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: irq/drivers] irqchip/imx-mu-msi: Fix PM domain teardown on probe errors
Date: Tue, 01 Dec 2026 09:09:30 -0000	[thread overview]
Message-ID: <179611617026.1190409.6932480696964898460.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20261115-imx-mu-msi-v1-2-8beb58854ca4@nxp.com>

The following commit has been merged into the irq/drivers branch of tip:

Commit-ID:     a6a5715e837b821c2a6c86f2bb7d4d225e2540d3
Gitweb:        https://git.kernel.org/tip/a6a5715e837b821c2a6c86f2bb7d4d225e2540d3
Author:        Peng Fan <peng.fan@nxp.com>
AuthorDate:    Sun, 15 Nov 2026 22:11:26 +08:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Tue, 01 Dec 2026 10:05:24 +01:00

irqchip/imx-mu-msi: Fix PM domain teardown on probe errors

dev_pm_domain_attach_by_name() creates a virtual device for each attached
PM domain, which must be released with dev_pm_domain_detach().

The probe error paths only remove the device links, leaking both virtual
devices. They also return -EINVAL instead of the actual error from
imx_mu_msi_domains_init() and logs the wrong domain name when the link for
the second domain cannot be created.

Detach the PM domains on every failure path and propagate the real
error code. Since the power-domains property is optional in the
fsl,mu-msi binding, treat a NULL domain as "not present" and skip the
corresponding device link rather than failing the probe.

Fixes: 70afdab904d2 ("irqchip: Add IMX MU MSI controller driver")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20261115-imx-mu-msi-v1-2-8beb58854ca4@nxp.com
---
 drivers/irqchip/irq-imx-mu-msi.c | 69 ++++++++++++++++++-------------
 1 file changed, 41 insertions(+), 28 deletions(-)

diff --git a/drivers/irqchip/irq-imx-mu-msi.c b/drivers/irqchip/irq-imx-mu-msi.c
index 3366fc4..2388f79 100644
--- a/drivers/irqchip/irq-imx-mu-msi.c
+++ b/drivers/irqchip/irq-imx-mu-msi.c
@@ -299,8 +299,8 @@ static const struct imx_mu_dcfg imx_mu_cfg_imx8ulp = {
 static int imx_mu_probe(struct platform_device *pdev, struct device_node *parent,
 			const struct imx_mu_dcfg *cfg)
 {
-	struct device_link *pd_link_a;
-	struct device_link *pd_link_b;
+	struct device_link *pd_link_a = NULL;
+	struct device_link *pd_link_b = NULL;
 	struct imx_mu_msi *msi_data;
 	struct resource *res;
 	struct device *pd_a;
@@ -344,33 +344,38 @@ static int imx_mu_probe(struct platform_device *pdev, struct device_node *parent
 		return PTR_ERR(pd_a);
 
 	pd_b = dev_pm_domain_attach_by_name(dev, "processor-b-side");
-	if (IS_ERR(pd_b))
-		return PTR_ERR(pd_b);
-
-	pd_link_a = device_link_add(dev, pd_a,
-			DL_FLAG_STATELESS |
-			DL_FLAG_PM_RUNTIME |
-			DL_FLAG_RPM_ACTIVE);
-
-	if (!pd_link_a) {
-		dev_err(dev, "Failed to add device_link to mu a.\n");
-		goto err_pd_a;
+	if (IS_ERR(pd_b)) {
+		ret = PTR_ERR(pd_b);
+		goto err_detach_a;
 	}
 
-	pd_link_b = device_link_add(dev, pd_b,
-			DL_FLAG_STATELESS |
-			DL_FLAG_PM_RUNTIME |
-			DL_FLAG_RPM_ACTIVE);
-
+	if (pd_a) {
+		pd_link_a = device_link_add(dev, pd_a,
+					    DL_FLAG_STATELESS |
+					    DL_FLAG_PM_RUNTIME |
+					    DL_FLAG_RPM_ACTIVE);
+		if (!pd_link_a) {
+			dev_err(dev, "Failed to add device_link to mu a.\n");
+			ret = -ENODEV;
+			goto err_detach;
+		}
+	}
 
-	if (!pd_link_b) {
-		dev_err(dev, "Failed to add device_link to mu a.\n");
-		goto err_pd_b;
+	if (pd_b) {
+		pd_link_b = device_link_add(dev, pd_b,
+					    DL_FLAG_STATELESS |
+					    DL_FLAG_PM_RUNTIME |
+					    DL_FLAG_RPM_ACTIVE);
+		if (!pd_link_b) {
+			dev_err(dev, "Failed to add device_link to mu b.\n");
+			ret = -ENODEV;
+			goto err_remove_link_a;
+		}
 	}
 
 	ret = imx_mu_msi_domains_init(msi_data, dev);
 	if (ret)
-		goto err_dm_init;
+		goto err_remove_links;
 
 	pm_runtime_enable(dev);
 
@@ -380,12 +385,20 @@ static int imx_mu_probe(struct platform_device *pdev, struct device_node *parent
 
 	return 0;
 
-err_dm_init:
-	device_link_remove(dev,	pd_b);
-err_pd_b:
-	device_link_remove(dev, pd_a);
-err_pd_a:
-	return -EINVAL;
+err_remove_links:
+	if (pd_link_b)
+		device_link_remove(dev, pd_b);
+err_remove_link_a:
+	if (pd_link_a)
+		device_link_remove(dev, pd_a);
+err_detach:
+	if (pd_b)
+		dev_pm_domain_detach(pd_b, true);
+err_detach_a:
+	if (pd_a)
+		dev_pm_domain_detach(pd_a, true);
+
+	return ret;
 }
 
 static int __maybe_unused imx_mu_runtime_suspend(struct device *dev)

      parent reply	other threads:[~2026-12-01  9:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-15 14:11 [PATCH 0/2] irqchip/imx-mu-msi: Fix MSI dispatch and probe error handling Peng Fan
2026-11-15 14:11 ` [PATCH 1/2] irqchip/imx-mu-msi: Fix MSI dispatch through the parent domain Peng Fan
2026-11-16 17:14   ` Frank Li
2026-12-01  9:09   ` [tip: irq/drivers] " tip-bot2 for Peng Fan
2026-11-15 14:11 ` [PATCH 2/2] irqchip/imx-mu-msi: Fix PM domain teardown on probe errors Peng Fan
2026-11-16 17:17   ` Frank Li
2026-12-01  9:09   ` tip-bot2 for Peng Fan [this message]

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=179611617026.1190409.6932480696964898460.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=Frank.Li@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=peng.fan@nxp.com \
    --cc=tglx@kernel.org \
    --cc=x86@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®