[PATCH] pmdomain: ti: Unregister TI SCI power domains on removal
Tian Xuechen
202300460064 at mail.sdu.edu.cn
Sun Nov 29 01:47:34 PST 2026
From: Tian Xuechen <202300460064 at mail.sdu.edu.cn>
The TI SCI OF provider and power domains outlive their managed storage
on removal. Remove the provider first and pair each successful domain
initialization with a cleanup action that also runs on probe failure.
This issue was found by our static analysis tool under development.
Fixes: efa5c01cd7ee ("soc: ti: ti_sci_pm_domains: switch to use multiple genpds instead of one")
Signed-off-by: Tian Xuechen <202300460064 at mail.sdu.edu.cn>
---
drivers/pmdomain/ti/ti_sci_pm_domains.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/drivers/pmdomain/ti/ti_sci_pm_domains.c b/drivers/pmdomain/ti/ti_sci_pm_domains.c
index 50898dc43310..efff66bf6917 100644
--- a/drivers/pmdomain/ti/ti_sci_pm_domains.c
+++ b/drivers/pmdomain/ti/ti_sci_pm_domains.c
@@ -218,6 +218,16 @@ static bool ti_sci_pm_pd_is_on(struct ti_sci_genpd_provider *pd_provider,
return is_on;
}
+static void ti_sci_pm_remove_domain(void *data)
+{
+ pm_genpd_remove(data);
+}
+
+static void ti_sci_pm_domain_remove(struct platform_device *pdev)
+{
+ of_genpd_del_provider(pdev->dev.of_node);
+}
+
static int ti_sci_pm_domain_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -226,7 +236,7 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev)
struct device_node *np __free(device_node) = NULL;
struct of_phandle_args args;
u32 max_id = 0;
- int index;
+ int index, ret;
pd_provider = devm_kzalloc_obj(dev, *pd_provider);
if (!pd_provider)
@@ -287,7 +297,14 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev)
is_on = ti_sci_pm_pd_is_on(pd_provider,
pd->idx);
- pm_genpd_init(&pd->pd, NULL, !is_on);
+ ret = pm_genpd_init(&pd->pd, NULL, !is_on);
+ if (ret)
+ return ret;
+
+ ret = devm_add_action_or_reset(dev, ti_sci_pm_remove_domain,
+ &pd->pd);
+ if (ret)
+ return ret;
list_add(&pd->node, &pd_provider->pd_list);
} else {
@@ -314,6 +331,7 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev)
static struct platform_driver ti_sci_pm_domains_driver = {
.probe = ti_sci_pm_domain_probe,
+ .remove = ti_sci_pm_domain_remove,
.driver = {
.name = "ti_sci_pm_domains",
.of_match_table = ti_sci_pm_domain_matches,
base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5
--
2.43.0
More information about the linux-arm-kernel
mailing list