[PATCH 1/2] pmdomain: amlogic: Tear down EE domains and their OF provider

Tian Xuechen 202300460064 at mail.sdu.edu.cn
Fri Nov 27 03:33:25 PST 2026


From: Tian Xuechen <202300460064 at mail.sdu.edu.cn>

The Meson EE power driver leaves the provider and domains registered
after freeing their backing storage. Remove the OF provider on unbind
and release initialized domains during managed cleanup, including when
probe fails.

This issue was found by our static analysis tool under development.

Fixes: eef3c2ba0a42 ("soc: amlogic: Add support for Everything-Else power domains controller")
Signed-off-by: Tian Xuechen <202300460064 at mail.sdu.edu.cn>
---
 drivers/pmdomain/amlogic/meson-ee-pwrc.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/pmdomain/amlogic/meson-ee-pwrc.c b/drivers/pmdomain/amlogic/meson-ee-pwrc.c
index 338f70d77bf0..f108d9337e5e 100644
--- a/drivers/pmdomain/amlogic/meson-ee-pwrc.c
+++ b/drivers/pmdomain/amlogic/meson-ee-pwrc.c
@@ -428,6 +428,16 @@ static int meson_ee_pwrc_on(struct generic_pm_domain *domain)
 				       pwrc_domain->clks);
 }
 
+static void meson_ee_pwrc_remove_domain(void *data)
+{
+	pm_genpd_remove(data);
+}
+
+static void meson_ee_pwrc_remove(struct platform_device *pdev)
+{
+	of_genpd_del_provider(pdev->dev.of_node);
+}
+
 static int meson_ee_pwrc_init_domain(struct platform_device *pdev,
 				     struct meson_ee_pwrc *pwrc,
 				     struct meson_ee_pwrc_domain *dom)
@@ -494,7 +504,8 @@ static int meson_ee_pwrc_init_domain(struct platform_device *pdev,
 			return ret;
 	}
 
-	return 0;
+	return devm_add_action_or_reset(&pdev->dev, meson_ee_pwrc_remove_domain,
+					&dom->base);
 }
 
 static int meson_ee_pwrc_probe(struct platform_device *pdev)
@@ -641,6 +652,7 @@ MODULE_DEVICE_TABLE(of, meson_ee_pwrc_match_table);
 
 static struct platform_driver meson_ee_pwrc_driver = {
 	.probe = meson_ee_pwrc_probe,
+	.remove = meson_ee_pwrc_remove,
 	.shutdown = meson_ee_pwrc_shutdown,
 	.driver = {
 		.name		= "meson_ee_pwrc",
-- 
2.43.0




More information about the linux-arm-kernel mailing list