linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched/cpufreq: Fix kobject memleak
@ 2019-04-30  0:11 Tobin C. Harding
  2019-04-30  4:22 ` Ingo Molnar
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Tobin C. Harding @ 2019-04-30  0:11 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra
  Cc: Tobin C. Harding, Greg Kroah-Hartman, linux-kernel

Currently error return from kobject_init_and_add() is not followed by a
call to kobject_put().  This means there is a memory leak.

Add call to kobject_put() in error path of kobject_init_and_add().
---
 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 5c41ea367422..3638d2377e3c 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;
 
 fail:
+	kobject_put(&tunables->attr_set.kobj);
 	policy->governor_data = NULL;
 	sugov_tunables_free(tunables);
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] sched/cpufreq: Fix kobject memleak
  2019-04-30  0:11 [PATCH] sched/cpufreq: Fix kobject memleak Tobin C. Harding
@ 2019-04-30  4:22 ` Ingo Molnar
  2019-04-30  5:52 ` [tip:sched/urgent] " tip-bot for Tobin C. Harding
  2019-04-30  6:01 ` tip-bot for Tobin C. Harding
  2 siblings, 0 replies; 6+ messages in thread
From: Ingo Molnar @ 2019-04-30  4:22 UTC (permalink / raw)
  To: Tobin C. Harding
  Cc: Ingo Molnar, Peter Zijlstra, Greg Kroah-Hartman, linux-kernel


* Tobin C. Harding <tobin@kernel.org> wrote:

> Currently error return from kobject_init_and_add() is not followed by a
> call to kobject_put().  This means there is a memory leak.
> 
> Add call to kobject_put() in error path of kobject_init_and_add().
> ---
>  kernel/sched/cpufreq_schedutil.c | 1 +
>  1 file changed, 1 insertion(+)

I've added your:

   Signed-off-by: Tobin C. Harding <tobin@kernel.org>

Which I suppose you intended to include?

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip:sched/urgent] sched/cpufreq: Fix kobject memleak
  2019-04-30  0:11 [PATCH] sched/cpufreq: Fix kobject memleak Tobin C. Harding
  2019-04-30  4:22 ` Ingo Molnar
@ 2019-04-30  5:52 ` tip-bot for Tobin C. Harding
  2019-04-30  5:56   ` Viresh Kumar
  2019-04-30  6:01 ` tip-bot for Tobin C. Harding
  2 siblings, 1 reply; 6+ messages in thread
From: tip-bot for Tobin C. Harding @ 2019-04-30  5:52 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, rafael.j.wysocki, mingo, tglx, hpa, gregkh,
	viresh.kumar, tobin, peterz, vincent.guittot, torvalds

Commit-ID:  8bf7ab9c79f3d1a5f02ebac369f656de9ec0aca8
Gitweb:     https://git.kernel.org/tip/8bf7ab9c79f3d1a5f02ebac369f656de9ec0aca8
Author:     Tobin C. Harding <tobin@kernel.org>
AuthorDate: Tue, 30 Apr 2019 10:11:44 +1000
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 30 Apr 2019 06:24:09 +0200

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
kobject_init_and_add().

Signed-off-by: Tobin C. Harding <tobin@kernel.org>
Add call to kobject_put() in error path of kobject_init_and_add().
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tobin C. Harding <tobin@kernel.org>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Link: http://lkml.kernel.org/r/20190430001144.24890-1-tobin@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 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 5c41ea367422..3638d2377e3c 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -771,6 +771,7 @@ out:
 	return 0;
 
 fail:
+	kobject_put(&tunables->attr_set.kobj);
 	policy->governor_data = NULL;
 	sugov_tunables_free(tunables);
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [tip:sched/urgent] sched/cpufreq: Fix kobject memleak
  2019-04-30  5:52 ` [tip:sched/urgent] " tip-bot for Tobin C. Harding
@ 2019-04-30  5:56   ` Viresh Kumar
  2019-04-30  6:27     ` Tobin C. Harding
  0 siblings, 1 reply; 6+ messages in thread
From: Viresh Kumar @ 2019-04-30  5:56 UTC (permalink / raw)
  To: mingo
  Cc: torvalds, gregkh, hpa, tglx, vincent.guittot, peterz,
	rafael.j.wysocki, tobin, linux-kernel, linux-tip-commits

On 29-04-19, 22:52, tip-bot for Tobin C. Harding wrote:
> Commit-ID:  8bf7ab9c79f3d1a5f02ebac369f656de9ec0aca8
> Gitweb:     https://git.kernel.org/tip/8bf7ab9c79f3d1a5f02ebac369f656de9ec0aca8
> Author:     Tobin C. Harding <tobin@kernel.org>
> AuthorDate: Tue, 30 Apr 2019 10:11:44 +1000
> Committer:  Ingo Molnar <mingo@kernel.org>
> CommitDate: Tue, 30 Apr 2019 06:24:09 +0200
> 
> 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
> kobject_init_and_add().
> 
> Signed-off-by: Tobin C. Harding <tobin@kernel.org>
> Add call to kobject_put() in error path of kobject_init_and_add().

This should have been present before the signed-off ?

> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Tobin C. Harding <tobin@kernel.org>
> Cc: Vincent Guittot <vincent.guittot@linaro.org>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Link: http://lkml.kernel.org/r/20190430001144.24890-1-tobin@kernel.org
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> ---
>  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 5c41ea367422..3638d2377e3c 100644
> --- a/kernel/sched/cpufreq_schedutil.c
> +++ b/kernel/sched/cpufreq_schedutil.c
> @@ -771,6 +771,7 @@ out:
>  	return 0;
>  
>  fail:
> +	kobject_put(&tunables->attr_set.kobj);
>  	policy->governor_data = NULL;
>  	sugov_tunables_free(tunables);
>  

-- 
viresh

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip:sched/urgent] sched/cpufreq: Fix kobject memleak
  2019-04-30  0:11 [PATCH] sched/cpufreq: Fix kobject memleak Tobin C. Harding
  2019-04-30  4:22 ` Ingo Molnar
  2019-04-30  5:52 ` [tip:sched/urgent] " tip-bot for Tobin C. Harding
@ 2019-04-30  6:01 ` tip-bot for Tobin C. Harding
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Tobin C. Harding @ 2019-04-30  6:01 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, tobin, gregkh, tglx, hpa, peterz, vincent.guittot,
	viresh.kumar, mingo, torvalds, rafael.j.wysocki

Commit-ID:  9a4f26cc98d81b67ecc23b890c28e2df324e29f3
Gitweb:     https://git.kernel.org/tip/9a4f26cc98d81b67ecc23b890c28e2df324e29f3
Author:     Tobin C. Harding <tobin@kernel.org>
AuthorDate: Tue, 30 Apr 2019 10:11:44 +1000
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 30 Apr 2019 07:57:23 +0200

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
kobject_init_and_add().

Signed-off-by: Tobin C. Harding <tobin@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tobin C. Harding <tobin@kernel.org>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Link: http://lkml.kernel.org/r/20190430001144.24890-1-tobin@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 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 5c41ea367422..3638d2377e3c 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -771,6 +771,7 @@ out:
 	return 0;
 
 fail:
+	kobject_put(&tunables->attr_set.kobj);
 	policy->governor_data = NULL;
 	sugov_tunables_free(tunables);
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [tip:sched/urgent] sched/cpufreq: Fix kobject memleak
  2019-04-30  5:56   ` Viresh Kumar
@ 2019-04-30  6:27     ` Tobin C. Harding
  0 siblings, 0 replies; 6+ messages in thread
From: Tobin C. Harding @ 2019-04-30  6:27 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: mingo, torvalds, gregkh, hpa, tglx, vincent.guittot, peterz,
	rafael.j.wysocki, tobin, linux-kernel, linux-tip-commits

On Tue, Apr 30, 2019 at 11:26:27AM +0530, Viresh Kumar wrote:
> On 29-04-19, 22:52, tip-bot for Tobin C. Harding wrote:
> > Commit-ID:  8bf7ab9c79f3d1a5f02ebac369f656de9ec0aca8
> > Gitweb:     https://git.kernel.org/tip/8bf7ab9c79f3d1a5f02ebac369f656de9ec0aca8
> > Author:     Tobin C. Harding <tobin@kernel.org>
> > AuthorDate: Tue, 30 Apr 2019 10:11:44 +1000
> > Committer:  Ingo Molnar <mingo@kernel.org>
> > CommitDate: Tue, 30 Apr 2019 06:24:09 +0200
> > 
> > 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
> > kobject_init_and_add().
> > 
> > Signed-off-by: Tobin C. Harding <tobin@kernel.org>
> > Add call to kobject_put() in error path of kobject_init_and_add().
> 
> This should have been present before the signed-off ?

Thanks.  Some face palm fails on this patch.  Its hard to get good help
:)

	Tobin

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-04-30  6:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-30  0:11 [PATCH] sched/cpufreq: Fix kobject memleak Tobin C. Harding
2019-04-30  4:22 ` Ingo Molnar
2019-04-30  5:52 ` [tip:sched/urgent] " tip-bot for Tobin C. Harding
2019-04-30  5:56   ` Viresh Kumar
2019-04-30  6:27     ` Tobin C. Harding
2019-04-30  6:01 ` tip-bot for Tobin C. Harding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).