From: Paul Mackerras Date: Wed, 11 Feb 2009 12:53:19 +0000 (+0100) Subject: perfcounters: fix refcounting bug, take 2 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=4bcf349a0f90d1e69eb35c6df0fa285c886c1cd6;p=linux-beck.git perfcounters: fix refcounting bug, take 2 Only free child_counter if it has a parent; if it doesn't, then it has a file pointing to it and we'll free it in perf_release. Signed-off-by: Mike Galbraith Signed-off-by: Ingo Molnar --- diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c index e0576c3fdb50..fcefb0a726f3 100644 --- a/kernel/perf_counter.c +++ b/kernel/perf_counter.c @@ -1958,14 +1958,13 @@ __perf_counter_exit_task(struct task_struct *child, sync_child_counter(child_counter, parent_counter); list_for_each_entry_safe(sub, tmp, &child_counter->sibling_list, list_entry) { - if (sub->parent) + if (sub->parent) { sync_child_counter(sub, sub->parent); - kfree(sub); + kfree(sub); + } } - } - - if (!child_counter->filp || !atomic_long_read(&child_counter->filp->f_count)) kfree(child_counter); + } } /*