Skip to content

Commit

Permalink
perfcounters: fix refcounting bug, take 2
Browse files Browse the repository at this point in the history
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 <efault@gmx.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Paul Mackerras authored and Ingo Molnar committed Feb 11, 2009
1 parent 5af7591 commit 4bcf349
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

/*
Expand Down

0 comments on commit 4bcf349

Please sign in to comment.