* [PATCH 1/2] pmdomain: amlogic: Tear down EE domains and their OF provider
2026-11-27 11:33 [PATCH 0/2] pmdomain: amlogic: Add teardown for EE and secure power domains Tian Xuechen
@ 2026-11-27 11:33 ` Tian Xuechen
2026-11-27 11:44 ` sashiko-bot
2026-11-27 11:33 ` [PATCH 2/2] pmdomain: amlogic: Tear down secure " Tian Xuechen
1 sibling, 1 reply; 4+ messages in thread
From: Tian Xuechen @ 2026-11-27 11:33 UTC (permalink / raw)
To: ulfh, neil.armstrong, khilman, jianxin.pan
Cc: jbrunet, martin.blumenstingl, linux-pm, linux-arm-kernel,
linux-amlogic
From: Tian Xuechen <202300460064@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@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
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2] pmdomain: amlogic: Tear down secure domains and their OF provider
2026-11-27 11:33 [PATCH 0/2] pmdomain: amlogic: Add teardown for EE and secure power domains Tian Xuechen
2026-11-27 11:33 ` [PATCH 1/2] pmdomain: amlogic: Tear down EE domains and their OF provider Tian Xuechen
@ 2026-11-27 11:33 ` Tian Xuechen
1 sibling, 0 replies; 4+ messages in thread
From: Tian Xuechen @ 2026-11-27 11:33 UTC (permalink / raw)
To: ulfh, neil.armstrong, khilman, jianxin.pan
Cc: jbrunet, martin.blumenstingl, linux-pm, linux-arm-kernel,
linux-amlogic
From: Tian Xuechen <202300460064@mail.sdu.edu.cn>
The secure power driver leaves the OF provider and domain hierarchy
registered after its memory is released. Remove the provider on unbind
and unwind subdomain links before the domains they connect. Use the same
cleanup when probe fails midway.
This issue was found by our static analysis tool under development.
Fixes: b3dde5013e13 ("soc: amlogic: Add support for Secure power domains controller")
Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
---
drivers/pmdomain/amlogic/meson-secure-pwrc.c | 36 ++++++++++++++++++--
1 file changed, 33 insertions(+), 3 deletions(-)
diff --git a/drivers/pmdomain/amlogic/meson-secure-pwrc.c b/drivers/pmdomain/amlogic/meson-secure-pwrc.c
index c424a1e76174..53e3fa10328e 100644
--- a/drivers/pmdomain/amlogic/meson-secure-pwrc.c
+++ b/drivers/pmdomain/amlogic/meson-secure-pwrc.c
@@ -392,9 +392,26 @@ static const struct meson_secure_pwrc_domain_desc t7_pwrc_domains[] = {
SEC_PD(T7_AUDIO, 0),
};
+static void meson_secure_pwrc_remove_domain(void *data)
+{
+ pm_genpd_remove(data);
+}
+
+static void meson_secure_pwrc_remove_subdomain(void *data)
+{
+ struct meson_secure_pwrc_domain *dom = data;
+
+ pm_genpd_remove_subdomain(&dom->pwrc->domains[dom->parent].base, &dom->base);
+}
+
+static void meson_secure_pwrc_remove(struct platform_device *pdev)
+{
+ of_genpd_del_provider(pdev->dev.of_node);
+}
+
static int meson_secure_pwrc_probe(struct platform_device *pdev)
{
- int i;
+ int i, ret;
struct device_node *sm_np;
struct meson_secure_pwrc *pwrc;
const struct meson_secure_pwrc_domain_data *match;
@@ -453,7 +470,13 @@ static int meson_secure_pwrc_probe(struct platform_device *pdev)
if (match->domains[i].is_off(dom) && (dom->base.flags & GENPD_FLAG_ALWAYS_ON))
meson_secure_pwrc_on(&dom->base);
- pm_genpd_init(&dom->base, NULL, match->domains[i].is_off(dom));
+ ret = pm_genpd_init(&dom->base, NULL, match->domains[i].is_off(dom));
+ if (ret)
+ return ret;
+ ret = devm_add_action_or_reset(&pdev->dev, meson_secure_pwrc_remove_domain,
+ &dom->base);
+ if (ret)
+ return ret;
pwrc->xlate.domains[i] = &dom->base;
}
@@ -464,7 +487,13 @@ static int meson_secure_pwrc_probe(struct platform_device *pdev)
if (!match->domains[i].name || match->domains[i].parent == PWRC_NO_PARENT)
continue;
- pm_genpd_add_subdomain(&dom[dom[i].parent].base, &dom[i].base);
+ ret = pm_genpd_add_subdomain(&dom[dom[i].parent].base, &dom[i].base);
+ if (ret)
+ return ret;
+ ret = devm_add_action_or_reset(&pdev->dev, meson_secure_pwrc_remove_subdomain,
+ &dom[i]);
+ if (ret)
+ return ret;
}
return of_genpd_add_provider_onecell(pdev->dev.of_node, &pwrc->xlate);
@@ -567,6 +596,7 @@ MODULE_DEVICE_TABLE(of, meson_secure_pwrc_match_table);
static struct platform_driver meson_secure_pwrc_driver = {
.probe = meson_secure_pwrc_probe,
+ .remove = meson_secure_pwrc_remove,
.driver = {
.name = "meson_secure_pwrc",
.of_match_table = meson_secure_pwrc_match_table,
--
2.43.0
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 4+ messages in thread