]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.180/sched-cpufreq-fix-kobject-memleak.patch
Linux 4.9.180
[thirdparty/kernel/stable-queue.git] / releases / 4.9.180 / sched-cpufreq-fix-kobject-memleak.patch
CommitLineData
2f47b8fc
SL
1From 780fcacb566d00d1e596b07dcd7a931c38ff5eff Mon Sep 17 00:00:00 2001
2From: Viresh Kumar <viresh.kumar@linaro.org>
3Date: Tue, 30 Apr 2019 11:35:52 +0530
4Subject: sched/cpufreq: Fix kobject memleak
5
6[ Upstream commit 9a4f26cc98d81b67ecc23b890c28e2df324e29f3 ]
7
8Currently the error return path from kobject_init_and_add() is not
9followed by a call to kobject_put() - which means we are leaking
10the kobject.
11
12Fix it by adding a call to kobject_put() in the error path of
13kobject_init_and_add().
14
15Signed-off-by: Tobin C. Harding <tobin@kernel.org>
16Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17Cc: Linus Torvalds <torvalds@linux-foundation.org>
18Cc: Peter Zijlstra <peterz@infradead.org>
19Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
20Cc: Thomas Gleixner <tglx@linutronix.de>
21Cc: Tobin C. Harding <tobin@kernel.org>
22Cc: Vincent Guittot <vincent.guittot@linaro.org>
23Cc: Viresh Kumar <viresh.kumar@linaro.org>
24Link: http://lkml.kernel.org/r/20190430001144.24890-1-tobin@kernel.org
25Signed-off-by: Ingo Molnar <mingo@kernel.org>
26Signed-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
32diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
33index 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
44diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
45index 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--
582.20.1
59