Blame libtracefs-Prevent-memory-leak-in-tracefs_event_syst.patch
|
Jerome Marchand |
3772ca |
From efdf7f7fcb9a4e0a5ccefb805d78123332aa7a23 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:19 +0200
|
|
Jerome Marchand |
3772ca |
Subject: [PATCH 05/15] libtracefs: Prevent memory leak in
|
|
Jerome Marchand |
3772ca |
tracefs_event_systems()
|
|
Jerome Marchand |
3772ca |
|
|
Jerome Marchand |
3772ca |
If an error is encountered in the loop, enable and sys might not get
|
|
Jerome Marchand |
3772ca |
freed. Move the calls to free() before possibly exiting the loop.
|
|
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-6-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 | 4 ++--
|
|
Jerome Marchand |
3772ca |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
Jerome Marchand |
3772ca |
|
|
Jerome Marchand |
3772ca |
diff --git a/src/tracefs-events.c b/src/tracefs-events.c
|
|
Jerome Marchand |
3772ca |
index 1b1693c..906dbe8 100644
|
|
Jerome Marchand |
3772ca |
--- a/src/tracefs-events.c
|
|
Jerome Marchand |
3772ca |
+++ b/src/tracefs-events.c
|
|
Jerome Marchand |
3772ca |
@@ -854,12 +854,12 @@ char **tracefs_event_systems(const char *tracing_dir)
|
|
Jerome Marchand |
3772ca |
enable = trace_append_file(sys, "enable");
|
|
Jerome Marchand |
3772ca |
|
|
Jerome Marchand |
3772ca |
ret = stat(enable, &st);
|
|
Jerome Marchand |
3772ca |
+ free(enable);
|
|
Jerome Marchand |
3772ca |
+ free(sys);
|
|
Jerome Marchand |
3772ca |
if (ret >= 0) {
|
|
Jerome Marchand |
3772ca |
if (add_list_string(&systems, name) < 0)
|
|
Jerome Marchand |
3772ca |
goto out_free;
|
|
Jerome Marchand |
3772ca |
}
|
|
Jerome Marchand |
3772ca |
- free(enable);
|
|
Jerome Marchand |
3772ca |
- free(sys);
|
|
Jerome Marchand |
3772ca |
}
|
|
Jerome Marchand |
3772ca |
|
|
Jerome Marchand |
3772ca |
closedir(dir);
|
|
Jerome Marchand |
3772ca |
--
|
|
Jerome Marchand |
3772ca |
2.45.2
|
|
Jerome Marchand |
3772ca |
|