tracing/user_events: Fix memory leak in user_event_create()
authorXiu Jianfeng <xiujianfeng@huawei.com>
Tue, 15 Nov 2022 01:44:45 +0000 (09:44 +0800)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Tue, 22 Nov 2022 23:09:50 +0000 (18:09 -0500)
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: e5d271812e7a ("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>
kernel/trace/trace_events_user.c

index ae78c2d..539b08a 100644 (file)
@@ -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);