Skip to content

Commit

Permalink
tracing/user_events: Fix memory leak in user_event_create()
Browse files Browse the repository at this point in the history
Before current_user_event_group(), it has allocated memory and save it
in @name, this should freed before return error.

Link: https://lkml.kernel.org/r/20221115014445.158419-1-xiujianfeng@huawei.com

Fixes: e5d2718 ("tracing/user_events: Move pages/locks into groups to prepare for namespaces")
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Acked-by: Beau Belgrave <beaub@linux.microsoft.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
  • Loading branch information
Xiu Jianfeng authored and Steven Rostedt (Google) committed Nov 22, 2022
1 parent 0a068f4 commit ccc6e59
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kernel/trace/trace_events_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -1100,8 +1100,10 @@ static int user_event_create(const char *raw_command)

group = current_user_event_group();

if (!group)
if (!group) {
kfree(name);
return -ENOENT;
}

mutex_lock(&group->reg_mutex);

Expand Down

0 comments on commit ccc6e59

Please sign in to comment.