]>
Commit | Line | Data |
---|---|---|
2f47b8fc SL |
1 | From 780fcacb566d00d1e596b07dcd7a931c38ff5eff Mon Sep 17 00:00:00 2001 |
2 | From: Viresh Kumar <viresh.kumar@linaro.org> | |
3 | Date: Tue, 30 Apr 2019 11:35:52 +0530 | |
4 | Subject: sched/cpufreq: Fix kobject memleak | |
5 | ||
6 | [ Upstream commit 9a4f26cc98d81b67ecc23b890c28e2df324e29f3 ] | |
7 | ||
8 | Currently the error return path from kobject_init_and_add() is not | |
9 | followed by a call to kobject_put() - which means we are leaking | |
10 | the kobject. | |
11 | ||
12 | Fix it by adding a call to kobject_put() in the error path of | |
13 | kobject_init_and_add(). | |
14 | ||
15 | Signed-off-by: Tobin C. Harding <tobin@kernel.org> | |
16 | Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
17 | Cc: Linus Torvalds <torvalds@linux-foundation.org> | |
18 | Cc: Peter Zijlstra <peterz@infradead.org> | |
19 | Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | |
20 | Cc: Thomas Gleixner <tglx@linutronix.de> | |
21 | Cc: Tobin C. Harding <tobin@kernel.org> | |
22 | Cc: Vincent Guittot <vincent.guittot@linaro.org> | |
23 | Cc: Viresh Kumar <viresh.kumar@linaro.org> | |
24 | Link: http://lkml.kernel.org/r/20190430001144.24890-1-tobin@kernel.org | |
25 | Signed-off-by: Ingo Molnar <mingo@kernel.org> | |
26 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
27 | --- | |
28 | drivers/cpufreq/cpufreq.c | 1 + | |
29 | drivers/cpufreq/cpufreq_governor.c | 2 ++ | |
30 | 2 files changed, 3 insertions(+) | |
31 | ||
32 | diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c | |
33 | index a38a23f0b3f41..e917521a3ef9b 100644 | |
34 | --- a/drivers/cpufreq/cpufreq.c | |
35 | +++ b/drivers/cpufreq/cpufreq.c | |
36 | @@ -1065,6 +1065,7 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) | |
37 | cpufreq_global_kobject, "policy%u", cpu); | |
38 | if (ret) { | |
39 | pr_err("%s: failed to init policy->kobj: %d\n", __func__, ret); | |
40 | + kobject_put(&policy->kobj); | |
41 | goto err_free_real_cpus; | |
42 | } | |
43 | ||
44 | diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c | |
45 | index 38d1a8216084c..32c9524a6ec54 100644 | |
46 | --- a/drivers/cpufreq/cpufreq_governor.c | |
47 | +++ b/drivers/cpufreq/cpufreq_governor.c | |
48 | @@ -449,6 +449,8 @@ int cpufreq_dbs_governor_init(struct cpufreq_policy *policy) | |
49 | /* Failure, so roll back. */ | |
50 | pr_err("initialization failed (dbs_data kobject init error %d)\n", ret); | |
51 | ||
52 | + kobject_put(&dbs_data->attr_set.kobj); | |
53 | + | |
54 | policy->governor_data = NULL; | |
55 | ||
56 | if (!have_governor_per_policy()) | |
57 | -- | |
58 | 2.20.1 | |
59 |