Skip to content

Commit 241e99d

Browse files
committed
Merge tag 'pmdomain-v6.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/linux-pm
Pull pmdomain fixes from Ulf Hansson: - imx: Fix reference count leak in ->remove() - samsung: Rework legacy splash-screen handover workaround - samsung: Fix potential memleak during ->probe() - arm: Fix genpd leak on provider registration failure for scmi * tag 'pmdomain-v6.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/linux-pm: pmdomain: imx: Fix reference count leak in imx_gpc_remove pmdomain: samsung: Rework legacy splash-screen handover workaround pmdomain: arm: scmi: Fix genpd leak on provider registration failure pmdomain: samsung: plug potential memleak during probe
2 parents 6014e75 + bbde146 commit 241e99d

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

drivers/pmdomain/arm/scmi_pm_domain.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static int scmi_pd_power_off(struct generic_pm_domain *domain)
4141

4242
static int scmi_pm_domain_probe(struct scmi_device *sdev)
4343
{
44-
int num_domains, i;
44+
int num_domains, i, ret;
4545
struct device *dev = &sdev->dev;
4646
struct device_node *np = dev->of_node;
4747
struct scmi_pm_domain *scmi_pd;
@@ -108,9 +108,18 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev)
108108
scmi_pd_data->domains = domains;
109109
scmi_pd_data->num_domains = num_domains;
110110

111+
ret = of_genpd_add_provider_onecell(np, scmi_pd_data);
112+
if (ret)
113+
goto err_rm_genpds;
114+
111115
dev_set_drvdata(dev, scmi_pd_data);
112116

113-
return of_genpd_add_provider_onecell(np, scmi_pd_data);
117+
return 0;
118+
err_rm_genpds:
119+
for (i = num_domains - 1; i >= 0; i--)
120+
pm_genpd_remove(domains[i]);
121+
122+
return ret;
114123
}
115124

116125
static void scmi_pm_domain_remove(struct scmi_device *sdev)

drivers/pmdomain/imx/gpc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,8 @@ static void imx_gpc_remove(struct platform_device *pdev)
536536
return;
537537
}
538538
}
539+
540+
of_node_put(pgc_node);
539541
}
540542

541543
static struct platform_driver imx_gpc_driver = {

drivers/pmdomain/samsung/exynos-pm-domains.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,14 @@ static const struct of_device_id exynos_pm_domain_of_match[] = {
9292
{ },
9393
};
9494

95-
static const char *exynos_get_domain_name(struct device_node *node)
95+
static const char *exynos_get_domain_name(struct device *dev,
96+
struct device_node *node)
9697
{
9798
const char *name;
9899

99100
if (of_property_read_string(node, "label", &name) < 0)
100101
name = kbasename(node->full_name);
101-
return kstrdup_const(name, GFP_KERNEL);
102+
return devm_kstrdup_const(dev, name, GFP_KERNEL);
102103
}
103104

104105
static int exynos_pd_probe(struct platform_device *pdev)
@@ -115,20 +116,27 @@ static int exynos_pd_probe(struct platform_device *pdev)
115116
if (!pd)
116117
return -ENOMEM;
117118

118-
pd->pd.name = exynos_get_domain_name(np);
119+
pd->pd.name = exynos_get_domain_name(dev, np);
119120
if (!pd->pd.name)
120121
return -ENOMEM;
121122

122123
pd->base = of_iomap(np, 0);
123-
if (!pd->base) {
124-
kfree_const(pd->pd.name);
124+
if (!pd->base)
125125
return -ENODEV;
126-
}
127126

128127
pd->pd.power_off = exynos_pd_power_off;
129128
pd->pd.power_on = exynos_pd_power_on;
130129
pd->local_pwr_cfg = pm_domain_cfg->local_pwr_cfg;
131130

131+
/*
132+
* Some Samsung platforms with bootloaders turning on the splash-screen
133+
* and handing it over to the kernel, requires the power-domains to be
134+
* reset during boot.
135+
*/
136+
if (IS_ENABLED(CONFIG_ARM) &&
137+
of_device_is_compatible(np, "samsung,exynos4210-pd"))
138+
exynos_pd_power_off(&pd->pd);
139+
132140
on = readl_relaxed(pd->base + 0x4) & pd->local_pwr_cfg;
133141

134142
pm_genpd_init(&pd->pd, NULL, !on);
@@ -147,15 +155,6 @@ static int exynos_pd_probe(struct platform_device *pdev)
147155
parent.np, child.np);
148156
}
149157

150-
/*
151-
* Some Samsung platforms with bootloaders turning on the splash-screen
152-
* and handing it over to the kernel, requires the power-domains to be
153-
* reset during boot. As a temporary hack to manage this, let's enforce
154-
* a sync_state.
155-
*/
156-
if (!ret)
157-
of_genpd_sync_state(np);
158-
159158
pm_runtime_enable(dev);
160159
return ret;
161160
}

0 commit comments

Comments
 (0)