diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 32b5d043203afe91fe977d8fd50d5d0064792057..5e9cd400ecb4ff71a4ddcc87d9b53168f5a9f380 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2351,7 +2351,10 @@ __register_event(struct trace_event_call *call, struct module *mod) if (ret < 0) return ret; + down_write(&trace_event_sem); list_add(&call->list, &ftrace_events); + up_write(&trace_event_sem); + call->mod = mod; return 0; @@ -2737,6 +2740,8 @@ __trace_add_event_dirs(struct trace_array *tr) struct trace_event_call *call; int ret; + lockdep_assert_held(&trace_event_sem); + list_for_each_entry(call, &ftrace_events, list) { ret = __trace_add_new_event(call, tr); if (ret < 0)