Blame libtracefs-Prevent-a-memory-leak-in-add_func_str.patch
|
Jerome Marchand |
3772ca |
From 7fcd8d27ff95670ffb0478486d408162f5299e89 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:21 +0200
|
|
Jerome Marchand |
3772ca |
Subject: [PATCH 07/15] libtracefs: Prevent a memory leak in add_func_str()
|
|
Jerome Marchand |
3772ca |
|
|
Jerome Marchand |
3772ca |
Free func_list if strdup() fails.
|
|
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-8-jmarchan@redhat.com
|
|
Jerome Marchand |
3772ca |
|
|
Jerome Marchand |
3772ca |
Fixes: c1606fb72264a ("libtracefs: Implement tracefs_filter_functions()")
|
|
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-tools.c | 4 +++-
|
|
Jerome Marchand |
3772ca |
1 file changed, 3 insertions(+), 1 deletion(-)
|
|
Jerome Marchand |
3772ca |
|
|
Jerome Marchand |
3772ca |
diff --git a/src/tracefs-tools.c b/src/tracefs-tools.c
|
|
Jerome Marchand |
3772ca |
index 8e7b46d..74cfe91 100644
|
|
Jerome Marchand |
3772ca |
--- a/src/tracefs-tools.c
|
|
Jerome Marchand |
3772ca |
+++ b/src/tracefs-tools.c
|
|
Jerome Marchand |
3772ca |
@@ -559,8 +559,10 @@ static int add_func_str(struct func_list ***next_func_ptr, const char *func)
|
|
Jerome Marchand |
3772ca |
if (!func_list)
|
|
Jerome Marchand |
3772ca |
return -1;
|
|
Jerome Marchand |
3772ca |
func_list->func = strdup(func);
|
|
Jerome Marchand |
3772ca |
- if (!func_list->func)
|
|
Jerome Marchand |
3772ca |
+ if (!func_list->func) {
|
|
Jerome Marchand |
3772ca |
+ free(func_list);
|
|
Jerome Marchand |
3772ca |
return -1;
|
|
Jerome Marchand |
3772ca |
+ }
|
|
Jerome Marchand |
3772ca |
*next_func = func_list;
|
|
Jerome Marchand |
3772ca |
return 0;
|
|
Jerome Marchand |
3772ca |
}
|
|
Jerome Marchand |
3772ca |
--
|
|
Jerome Marchand |
3772ca |
2.45.2
|
|
Jerome Marchand |
3772ca |
|