public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tracing/user_events: Fix memory leak in user_event_create()
@ 2022-11-15  1:44 Xiu Jianfeng
  2022-11-15 15:07 ` Masami Hiramatsu
  0 siblings, 1 reply; 3+ messages in thread
From: Xiu Jianfeng @ 2022-11-15  1:44 UTC (permalink / raw)
  To: rostedt, mhiramat, beaub; +Cc: linux-kernel

Before current_user_event_group(), it has allocated memory and save it
in @name, this should freed before return error.

Fixes: e5d271812e7a ("tracing/user_events: Move pages/locks into groups to prepare for namespaces")
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
 kernel/trace/trace_events_user.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c
index ae78c2d53c8a..539b08ae7020 100644
--- a/kernel/trace/trace_events_user.c
+++ b/kernel/trace/trace_events_user.c
@@ -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);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-15 17:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-15  1:44 [PATCH] tracing/user_events: Fix memory leak in user_event_create() Xiu Jianfeng
2022-11-15 15:07 ` Masami Hiramatsu
2022-11-15 17:07   ` Beau Belgrave

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox