sched/cpufreq: Fix kobject memleak [Linux 5.1]

sched/cpufreq: Fix kobject memleak [Linux 5.1]

This Linux kernel change "sched/cpufreq: Fix kobject memleak" is included in the Linux 5.1 release. This change is authored by Tobin C. Harding <tobin [at]> on Tue Apr 30 10:11:44 2019 +1000. The commit for this change in Linux stable tree is 9a4f26c (patch).

sched/cpufreq: Fix kobject memleak

Currently the error return path from kobject_init_and_add() is not
followed by a call to kobject_put() - which means we are leaking
the kobject.

Fix it by adding a call to kobject_put() in the error path of

Signed-off-by: Tobin C. Harding <>
Cc: Greg Kroah-Hartman <>
Cc: Linus Torvalds <>
Cc: Peter Zijlstra <>
Cc: Rafael J. Wysocki <>
Cc: Thomas Gleixner <>
Cc: Tobin C. Harding <>
Cc: Vincent Guittot <>
Cc: Viresh Kumar <>
Signed-off-by: Ingo Molnar <>

There is one line of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 kernel/sched/cpufreq_schedutil.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index 5c41ea3..3638d23 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -771,6 +771,7 @@ static int sugov_init(struct cpufreq_policy *policy)
    return 0;

+   kobject_put(&tunables->attr_set.kobj);
    policy->governor_data = NULL;

Leave a Reply

Your email address will not be published. Required fields are marked *