Skip to contentSkip to conversation

sched: fix struct autogroup memory leak

PATCH In review Mike Galbraith 2 participants 4 messages Jan 5, 2011 – Jan 7, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched: fix struct autogroup memory leak

Seems I lost a change somewhere, leaking memory.

sched: fix struct autogroup memory leak

Add missing change to actually use autogroup_free().

Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 kernel/sched.c           |    1 +
 kernel/sched_autogroup.c |    3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
kernel/sched.c +1 -0
Index: linux-2.6/kernel/sched.c
===================================================================
@@ -8382,6 +8382,7 @@ static void free_sched_group(struct task
 {
 	free_fair_sched_group(tg);
 	free_rt_sched_group(tg);
+	autogroup_free(tg);
 	kfree(tg);
 }
 
kernel/sched_autogroup.c +2 -1
Index: linux-2.6/kernel/sched_autogroup.c
===================================================================
@@ -20,7 +20,8 @@ static void autogroup_init(struct task_s
 
 static inline void autogroup_free(struct task_group *tg)
 {
-	kfree(tg->autogroup);
+	if (tg->autogroup)
+		kfree(tg->autogroup);
 }
 
 static inline void autogroup_destroy(struct kref *kref)
#1 lore raw

kernel/sched_autogroup.c static void autogroup_init(struct task_s · line 25

Quoted 6 lines · Mike Galbraith

static inline void autogroup_free(struct task_group *tg) {

kernel/sched_autogroup.c +2 -1
-	kfree(tg->autogroup);
+	if (tg->autogroup)
+		kfree(tg->autogroup);
 }

WARNING: kfree(NULL) is safe this check is probably not required #43: FILE: kernel/sched_autogroup.c:24:
+ if (tg->autogroup)
+ kfree(tg->autogroup);

#2 lore raw

Review

Quoted 13 lines · Peter Zijlstra

Review

Quoted 6 lines · Mike Galbraith

static inline void autogroup_free(struct task_group *tg) {

(quoted diff) +2 -1
-	kfree(tg->autogroup);
+	if (tg->autogroup)
+		kfree(tg->autogroup);
 }

WARNING: kfree(NULL) is safe this check is probably not required #43: FILE: kernel/sched_autogroup.c:24:

(quoted diff) +2 -0
+       if (tg->autogroup)
+               kfree(tg->autogroup);

Once upon a time, I knew that.

sched: fix struct autogroup memory leak

Add missing change to actually use autogroup_free().

Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 kernel/sched.c |    1 +
 1 file changed, 1 insertion(+)
kernel/sched.c +1 -0
Index: linux-2.6/kernel/sched.c
===================================================================
@@ -8382,6 +8382,7 @@ static void free_sched_group(struct task
 {
 	free_fair_sched_group(tg);
 	free_rt_sched_group(tg);
+	autogroup_free(tg);
 	kfree(tg);
 }
 
#3 lore raw

[tip:sched/urgent] sched: Fix struct autogroup memory leak

In reply to Mike Galbraith
Commit-ID:  e9aa1dd19fe49b5aed3ca94aab87576e534d2a39
Gitweb:     http://git.kernel.org/tip/e9aa1dd19fe49b5aed3ca94aab87576e534d2a39
Author:     Mike Galbraith <[email protected]>
AuthorDate: Wed, 5 Jan 2011 11:11:25 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 7 Jan 2011 15:54:37 +0100

sched: Fix struct autogroup memory leak

Seems I lost a change somewhere, leaking memory.

sched: fix struct autogroup memory leak

Add missing change to actually use autogroup_free().

LKML-Reference: <[email protected]>

---
 kernel/sched.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
kernel/sched.c +1 -0
index 54b58ec..a8478a2 100644
@@ -8377,6 +8377,7 @@ static void free_sched_group(struct task_group *tg)
 {
 	free_fair_sched_group(tg);
 	free_rt_sched_group(tg);
+	autogroup_free(tg);
 	kfree(tg);
 }