Linux Kernels

perf_events, trace: Fix perf_trace_destroy(), mutex went missing

This change “perf_events, trace: Fix perf_trace_destroy(), mutex went missing” (commit 2e97942) in Linux kernel is authored by Peter Zijlstra <a.p.zijlstra [at] chello.nl> on Fri May 21 16:22:33 2010 +0200.

Description of "perf_events, trace: Fix perf_trace_destroy(), mutex went missing"

The change “perf_events, trace: Fix perf_trace_destroy(), mutex went missing” introduces changes as follows.

perf_events, trace: Fix perf_trace_destroy(), mutex went missing

Steve spotted I forgot to do the destroy under event_mutex.

Reported-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <1274451913.1674.1707.camel@laptop>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Linux kernel releases containing commit 2e97942

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "perf_events, trace: Fix perf_trace_destroy(), mutex went missing"

There are 5 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 kernel/trace/trace_event_perf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
 
diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
index 49c7abf2ba5c..e6f65887842c 100644
--- a/kernel/trace/trace_event_perf.c
+++ b/kernel/trace/trace_event_perf.c
@@ -132,8 +132,9 @@ void perf_trace_destroy(struct perf_event *p_event)
 	struct ftrace_event_call *tp_event = p_event->tp_event;
 	int i;
 
+	mutex_lock(&event_mutex);
 	if (--tp_event->perf_refcount > 0)
-		return;
+		goto out;
 
 	if (tp_event->class->reg)
 		tp_event->class->reg(tp_event, TRACE_REG_PERF_UNREGISTER);
@@ -157,6 +158,8 @@ void perf_trace_destroy(struct perf_event *p_event)
 			perf_trace_buf[i] = NULL;
 		}
 	}
+out:
+	mutex_unlock(&event_mutex);
 }
 
 __kprobes void *perf_trace_buf_prepare(int size, unsigned short type,

The commit for this change in Linux stable tree is 2e97942 (patch).

Last modified: 2020/01/11 09:37