Commit ddde2add authored by Lucas Stach's avatar Lucas Stach Committed by Kamal Mostafa

cpufreq: cpu0: drop wrong devm usage

commit e3beb0ac upstream.

This driver is using devres managed calls incorrectly, giving the cpu0
device as first parameter instead of the cpufreq platform device.
This results in resources not being freed if the cpufreq platform device
is unbound, for example if probing has to be deferred for a missing
regulator.
Signed-off-by: default avatarLucas Stach <l.stach@pengutronix.de>
Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent 4e5439ed
...@@ -131,7 +131,7 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev) ...@@ -131,7 +131,7 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev)
return -ENOENT; return -ENOENT;
} }
cpu_reg = devm_regulator_get_optional(cpu_dev, "cpu0"); cpu_reg = regulator_get_optional(cpu_dev, "cpu0");
if (IS_ERR(cpu_reg)) { if (IS_ERR(cpu_reg)) {
/* /*
* If cpu0 regulator supply node is present, but regulator is * If cpu0 regulator supply node is present, but regulator is
...@@ -146,23 +146,23 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev) ...@@ -146,23 +146,23 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev)
PTR_ERR(cpu_reg)); PTR_ERR(cpu_reg));
} }
cpu_clk = devm_clk_get(cpu_dev, NULL); cpu_clk = clk_get(cpu_dev, NULL);
if (IS_ERR(cpu_clk)) { if (IS_ERR(cpu_clk)) {
ret = PTR_ERR(cpu_clk); ret = PTR_ERR(cpu_clk);
pr_err("failed to get cpu0 clock: %d\n", ret); pr_err("failed to get cpu0 clock: %d\n", ret);
goto out_put_node; goto out_put_reg;
} }
ret = of_init_opp_table(cpu_dev); ret = of_init_opp_table(cpu_dev);
if (ret) { if (ret) {
pr_err("failed to init OPP table: %d\n", ret); pr_err("failed to init OPP table: %d\n", ret);
goto out_put_node; goto out_put_clk;
} }
ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table); ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);
if (ret) { if (ret) {
pr_err("failed to init cpufreq table: %d\n", ret); pr_err("failed to init cpufreq table: %d\n", ret);
goto out_put_node; goto out_put_clk;
} }
of_property_read_u32(np, "voltage-tolerance", &voltage_tolerance); of_property_read_u32(np, "voltage-tolerance", &voltage_tolerance);
...@@ -206,6 +206,12 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev) ...@@ -206,6 +206,12 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev)
out_free_table: out_free_table:
dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
out_put_clk:
if (!IS_ERR(cpu_clk))
clk_put(cpu_clk);
out_put_reg:
if (!IS_ERR(cpu_reg))
regulator_put(cpu_reg);
out_put_node: out_put_node:
of_node_put(np); of_node_put(np);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment