mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pengpeng Hou <pengpeng@iscas.ac.cn>
To: Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>,
	linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Pengpeng Hou <pengpeng@iscas.ac.cn>
Subject: [PATCH] soc: qcom: rpmh-rsc: unwind notifiers on populate failure
Date: Tue, 16 Jun 2026 08:56:18 +0800	[thread overview]
Message-ID: <20260616005618.9328-1-pengpeng@iscas.ac.cn> (raw)

rpmh_rsc_probe() registers either a genpd notifier or a CPU PM notifier
before populating child devices.  The genpd path is unwound if child
population fails, but the CPU PM notifier registration return value is
ignored and the notifier remains registered on the same failure path.

Check the CPU PM notifier registration result and unregister it if child
population fails.  Also depopulate any children that were created before
devm_of_platform_populate() returned an error, because the devres cleanup
action is only installed after successful population.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
 drivers/soc/qcom/rpmh-rsc.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index c6f7d5c9c493..a75ff97423e8 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -1033,6 +1033,7 @@ static int rpmh_rsc_probe(struct platform_device *pdev)
 	struct device_node *dn = pdev->dev.of_node;
 	struct rsc_drv *drv;
 	char drv_id[10] = {0};
+	bool cpu_pm_registered = false;
 	int ret, irq;
 	u32 solver_config;
 	u32 rsc_id;
@@ -1107,7 +1108,10 @@ static int rpmh_rsc_probe(struct platform_device *pdev)
 				return ret;
 		} else {
 			drv->rsc_pm.notifier_call = rpmh_rsc_cpu_pm_callback;
-			cpu_pm_register_notifier(&drv->rsc_pm);
+			ret = cpu_pm_register_notifier(&drv->rsc_pm);
+			if (ret)
+				return ret;
+			cpu_pm_registered = true;
 		}
 	}
 
@@ -1123,9 +1127,14 @@ static int rpmh_rsc_probe(struct platform_device *pdev)
 	drv->dev = &pdev->dev;
 
 	ret = devm_of_platform_populate(&pdev->dev);
-	if (ret && pdev->dev.pm_domain) {
-		dev_pm_genpd_remove_notifier(&pdev->dev);
-		pm_runtime_disable(&pdev->dev);
+	if (ret) {
+		of_platform_depopulate(&pdev->dev);
+		if (pdev->dev.pm_domain) {
+			dev_pm_genpd_remove_notifier(&pdev->dev);
+			pm_runtime_disable(&pdev->dev);
+		} else if (cpu_pm_registered) {
+			cpu_pm_unregister_notifier(&drv->rsc_pm);
+		}
 	}
 
 	return ret;
-- 
2.50.1 (Apple Git-155)


             reply	other threads:[~2026-06-16  0:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-16  0:56 Pengpeng Hou [this message]
2026-06-17 11:46 ` Konrad Dybcio

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=20260616005618.9328-1-pengpeng@iscas.ac.cn \
    --to=pengpeng@iscas.ac.cn \
    --cc=andersson@kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.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®