Re: [PATCH] sched: try to fix mm leak when freeing sched groups

From: Hillf Danton
Date: Sun May 01 2011 - 22:39:26 EST


On Thu, Apr 21, 2011 at 10:20 PM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> On Thu, 2011-04-21 at 21:46 +0800, Hillf Danton wrote:
>>
>> It is linux-2.6.39-rc1.tar.bz2 downloaded at kernel.org, and
>> Â Â Â Â Â >> --- a/kernel/sched.c Â2011-03-30 03:09:48.000000000 +0800
>> is the time stamp, right?
>
> Dunno, but 39-rc1 is like ancient, please send patches against the tip
> git tree:
>
> Âgit://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git
>

Hi Peter

I tried again, and please review once more.

thanks

Hillf
---

--- linux-2.6.39-rc5/kernel/sched.c 2011-04-27 11:48:50.000000000 +0800
+++ sched.c 2011-05-02 10:38:02.000000000 +0800
@@ -7120,21 +7120,18 @@ static void free_sched_groups(const stru
continue;

for (i = 0; i < nr_node_ids; i++) {
- struct sched_group *oldsg, *sg = sched_group_nodes[i];
+ struct sched_group *sg = sched_group_nodes[i];

cpumask_and(nodemask, cpumask_of_node(i), cpu_map);
if (cpumask_empty(nodemask))
continue;

- if (sg == NULL)
- continue;
- sg = sg->next;
-next_sg:
- oldsg = sg;
- sg = sg->next;
- kfree(oldsg);
- if (oldsg != sched_group_nodes[i])
- goto next_sg;
+ if (sg != NULL)
+ do {
+ struct sched_group *next = sg->next;
+ kfree(sg);
+ sg = next;
+ } while (sg != sched_group_nodes[i]);
}
kfree(sched_group_nodes);
sched_group_nodes_bycpu[cpu] = NULL;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/