aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-03-19 20:26:16 +0100
committerIngo Molnar <mingo@elte.hu>2009-04-06 09:30:16 +0200
commitf16009527595ee562308653bc3d0039166d2ab15 (patch)
tree1fc6f2e5632bd0b2c624ed106a047d6d2127e59c
parent4a0deca657f3dbb8a707b5dc8f173beec01e7ed2 (diff)
perf_counter: fix up counter free paths
Impact: fix crash during perfcounters use I found another counter free path, create a free_counter() call to accomodate generic tear-down. Fixes an RCU bug. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Cc: Steven Rostedt <rostedt@goodmis.org> Orig-LKML-Reference: <20090319194233.652078652@chello.nl> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--kernel/perf_counter.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index 99d5930f0a5..97f891ffeb4 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -1150,6 +1150,11 @@ static void free_counter_rcu(struct rcu_head *head)
kfree(counter);
}
+static void free_counter(struct perf_counter *counter)
+{
+ call_rcu(&counter->rcu_head, free_counter_rcu);
+}
+
/*
* Called when the last reference to the file is gone.
*/
@@ -1168,7 +1173,7 @@ static int perf_release(struct inode *inode, struct file *file)
mutex_unlock(&counter->mutex);
mutex_unlock(&ctx->mutex);
- call_rcu(&counter->rcu_head, free_counter_rcu);
+ free_counter(counter);
put_context(ctx);
return 0;
@@ -2128,10 +2133,10 @@ __perf_counter_exit_task(struct task_struct *child,
list_entry) {
if (sub->parent) {
sync_child_counter(sub, sub->parent);
- kfree(sub);
+ free_counter(sub);
}
}
- kfree(child_counter);
+ free_counter(child_counter);
}
}