]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.14.7/cpufreq-cpu0-drop-wrong-devm-usage.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.14.7 / cpufreq-cpu0-drop-wrong-devm-usage.patch
CommitLineData
c15ed09d
GKH
1From e3beb0ac521d50d158a9d253373eae8421ac3998 Mon Sep 17 00:00:00 2001
2From: Lucas Stach <l.stach@pengutronix.de>
3Date: Fri, 16 May 2014 12:20:42 +0200
4Subject: cpufreq: cpu0: drop wrong devm usage
5
6From: Lucas Stach <l.stach@pengutronix.de>
7
8commit e3beb0ac521d50d158a9d253373eae8421ac3998 upstream.
9
10This driver is using devres managed calls incorrectly, giving the cpu0
11device as first parameter instead of the cpufreq platform device.
12This results in resources not being freed if the cpufreq platform device
13is unbound, for example if probing has to be deferred for a missing
14regulator.
15
16Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
17Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
18Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
19Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20
21---
22 drivers/cpufreq/cpufreq-cpu0.c | 16 +++++++++++-----
23 1 file changed, 11 insertions(+), 5 deletions(-)
24
25--- a/drivers/cpufreq/cpufreq-cpu0.c
26+++ b/drivers/cpufreq/cpufreq-cpu0.c
27@@ -131,7 +131,7 @@ static int cpu0_cpufreq_probe(struct pla
28 return -ENOENT;
29 }
30
31- cpu_reg = devm_regulator_get_optional(cpu_dev, "cpu0");
32+ cpu_reg = regulator_get_optional(cpu_dev, "cpu0");
33 if (IS_ERR(cpu_reg)) {
34 /*
35 * If cpu0 regulator supply node is present, but regulator is
36@@ -146,23 +146,23 @@ static int cpu0_cpufreq_probe(struct pla
37 PTR_ERR(cpu_reg));
38 }
39
40- cpu_clk = devm_clk_get(cpu_dev, NULL);
41+ cpu_clk = clk_get(cpu_dev, NULL);
42 if (IS_ERR(cpu_clk)) {
43 ret = PTR_ERR(cpu_clk);
44 pr_err("failed to get cpu0 clock: %d\n", ret);
45- goto out_put_node;
46+ goto out_put_reg;
47 }
48
49 ret = of_init_opp_table(cpu_dev);
50 if (ret) {
51 pr_err("failed to init OPP table: %d\n", ret);
52- goto out_put_node;
53+ goto out_put_clk;
54 }
55
56 ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);
57 if (ret) {
58 pr_err("failed to init cpufreq table: %d\n", ret);
59- goto out_put_node;
60+ goto out_put_clk;
61 }
62
63 of_property_read_u32(np, "voltage-tolerance", &voltage_tolerance);
64@@ -217,6 +217,12 @@ static int cpu0_cpufreq_probe(struct pla
65
66 out_free_table:
67 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
68+out_put_clk:
69+ if (!IS_ERR(cpu_clk))
70+ clk_put(cpu_clk);
71+out_put_reg:
72+ if (!IS_ERR(cpu_reg))
73+ regulator_put(cpu_reg);
74 out_put_node:
75 of_node_put(np);
76 return ret;