Blame libtracefs-Prevent-a-memory-leak-in-tracefs_system_e.patch
|
Jerome Marchand |
3772ca |
From 7d77b83ce83c318cb83cf2529f45cc950edb44d5 Mon Sep 17 00:00:00 2001
|
|
Jerome Marchand |
3772ca |
From: Jerome Marchand <jmarchan@redhat.com>
|
|
Jerome Marchand |
3772ca |
Date: Thu, 6 Jun 2024 17:38:22 +0200
|
|
Jerome Marchand |
3772ca |
Subject: [PATCH 08/15] libtracefs: Prevent a memory leak in
|
|
Jerome Marchand |
3772ca |
tracefs_system_events()
|
|
Jerome Marchand |
3772ca |
|
|
Jerome Marchand |
3772ca |
If add_list_string() fails, event isn't freed. Free event before
|
|
Jerome Marchand |
3772ca |
calling add_list_string();
|
|
Jerome Marchand |
3772ca |
|
|
Jerome Marchand |
3772ca |
Fixes a RESSOURCE_LEAK error (CWE-772)
|
|
Jerome Marchand |
3772ca |
|
|
Jerome Marchand |
3772ca |
Link: https://lore.kernel.org/linux-trace-devel/20240606153830.2666120-9-jmarchan@redhat.com
|
|
Jerome Marchand |
3772ca |
|
|
Jerome Marchand |
3772ca |
Fixes: 056a177e1d686 ("libtracefs: Restructure how string lists work")
|
|
Jerome Marchand |
3772ca |
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
|
|
Jerome Marchand |
3772ca |
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
|
|
Jerome Marchand |
3772ca |
---
|
|
Jerome Marchand |
3772ca |
src/tracefs-events.c | 3 +--
|
|
Jerome Marchand |
3772ca |
1 file changed, 1 insertion(+), 2 deletions(-)
|
|
Jerome Marchand |
3772ca |
|
|
Jerome Marchand |
3772ca |
diff --git a/src/tracefs-events.c b/src/tracefs-events.c
|
|
Jerome Marchand |
3772ca |
index 906dbe8..d65837e 100644
|
|
Jerome Marchand |
3772ca |
--- a/src/tracefs-events.c
|
|
Jerome Marchand |
3772ca |
+++ b/src/tracefs-events.c
|
|
Jerome Marchand |
3772ca |
@@ -919,11 +919,10 @@ char **tracefs_system_events(const char *tracing_dir, const char *system)
|
|
Jerome Marchand |
3772ca |
free(event);
|
|
Jerome Marchand |
3772ca |
continue;
|
|
Jerome Marchand |
3772ca |
}
|
|
Jerome Marchand |
3772ca |
+ free(event);
|
|
Jerome Marchand |
3772ca |
|
|
Jerome Marchand |
3772ca |
if (add_list_string(&events, name) < 0)
|
|
Jerome Marchand |
3772ca |
goto out_free;
|
|
Jerome Marchand |
3772ca |
-
|
|
Jerome Marchand |
3772ca |
- free(event);
|
|
Jerome Marchand |
3772ca |
}
|
|
Jerome Marchand |
3772ca |
|
|
Jerome Marchand |
3772ca |
closedir(dir);
|
|
Jerome Marchand |
3772ca |
--
|
|
Jerome Marchand |
3772ca |
2.45.2
|
|
Jerome Marchand |
3772ca |
|