diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2009-08-24 00:19:47 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-09-12 22:28:38 -0400 |
commit | 558e6547e4b8a2b13608a24a9d3679802f91c4c7 (patch) | |
tree | aa7eeeee57fbf93d2ff3811a362ffef19be17c29 /kernel/trace | |
parent | 4818d80942b7c0021d213b7c5f1a14a832820a01 (diff) |
tracing/profile: fix profile_disable vs module_unload
If the correspoding module is unloaded before ftrace_profile_disable()
is called, event->profile_disable() won't be called, which can
cause oops:
# insmod trace-events-sample.ko
# perf record -f -a -e sample:foo_bar sleep 3 &
# sleep 1
# rmmod trace_events_sample
# insmod trace-events-sample.ko
OOPS!
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4A9214E3.2070807@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/trace_event_profile.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/kernel/trace/trace_event_profile.c b/kernel/trace/trace_event_profile.c index 11ba5bb4ed0a..55a25c933d15 100644 --- a/kernel/trace/trace_event_profile.c +++ b/kernel/trace/trace_event_profile.c | |||
@@ -5,6 +5,7 @@ | |||
5 | * | 5 | * |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include <linux/module.h> | ||
8 | #include "trace.h" | 9 | #include "trace.h" |
9 | 10 | ||
10 | int ftrace_profile_enable(int event_id) | 11 | int ftrace_profile_enable(int event_id) |
@@ -14,7 +15,8 @@ int ftrace_profile_enable(int event_id) | |||
14 | 15 | ||
15 | mutex_lock(&event_mutex); | 16 | mutex_lock(&event_mutex); |
16 | list_for_each_entry(event, &ftrace_events, list) { | 17 | list_for_each_entry(event, &ftrace_events, list) { |
17 | if (event->id == event_id && event->profile_enable) { | 18 | if (event->id == event_id && event->profile_enable && |
19 | try_module_get(event->mod)) { | ||
18 | ret = event->profile_enable(event); | 20 | ret = event->profile_enable(event); |
19 | break; | 21 | break; |
20 | } | 22 | } |
@@ -32,6 +34,7 @@ void ftrace_profile_disable(int event_id) | |||
32 | list_for_each_entry(event, &ftrace_events, list) { | 34 | list_for_each_entry(event, &ftrace_events, list) { |
33 | if (event->id == event_id) { | 35 | if (event->id == event_id) { |
34 | event->profile_disable(event); | 36 | event->profile_disable(event); |
37 | module_put(event->mod); | ||
35 | break; | 38 | break; |
36 | } | 39 | } |
37 | } | 40 | } |