From: Beau Belgrave Date: Mon, 28 Mar 2022 22:32:25 +0000 (-0700) Subject: tracing/user_events: Hold event_mutex during dyn_event_add X-Git-Tag: v6.1-rc5~1611^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=efe34e99fc41ad2b3fd3bbe79ecd3906620ec961;p=platform%2Fkernel%2Flinux-starfive.git tracing/user_events: Hold event_mutex during dyn_event_add Make sure the event_mutex is properly held during dyn_event_add call. This is required when adding dynamic events. Link: https://lkml.kernel.org/r/20220328223225.1992-1-beaub@linux.microsoft.com Reported-by: Mathieu Desnoyers Signed-off-by: Beau Belgrave Acked-by: Masami Hiramatsu Signed-off-by: Steven Rostedt (Google) --- diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index 8b3d241..61d78d6 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -1165,11 +1165,11 @@ static int user_event_parse(char *name, char *args, char *flags, #endif mutex_lock(&event_mutex); + ret = user_event_trace_register(user); - mutex_unlock(&event_mutex); if (ret) - goto put_user; + goto put_user_lock; user->index = index; @@ -1181,8 +1181,12 @@ static int user_event_parse(char *name, char *args, char *flags, set_bit(user->index, page_bitmap); hash_add(register_table, &user->node, key); + mutex_unlock(&event_mutex); + *newuser = user; return 0; +put_user_lock: + mutex_unlock(&event_mutex); put_user: user_event_destroy_fields(user); user_event_destroy_validators(user);