Blame libtracefs-Close-dir-in-the-error-path-in-tracefs_sy.patch

Jerome Marchand 3772ca
From 0309a876ba3ac13f7a436f292a6bdc0927213a76 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:27 +0200
Jerome Marchand 3772ca
Subject: [PATCH 13/15] libtracefs: Close dir in the error path in
Jerome Marchand 3772ca
 tracefs_system_events()
Jerome Marchand 3772ca
Jerome Marchand 3772ca
In tracefs_system_events(), we don't close dir if add_list_string()
Jerome Marchand 3772ca
fails. At this point, just breaking out of the loop fixes that.
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-14-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 | 2 +-
Jerome Marchand 3772ca
 1 file changed, 1 insertion(+), 1 deletion(-)
Jerome Marchand 3772ca
Jerome Marchand 3772ca
diff --git a/src/tracefs-events.c b/src/tracefs-events.c
Jerome Marchand 3772ca
index 88325e1..1fa3f2f 100644
Jerome Marchand 3772ca
--- a/src/tracefs-events.c
Jerome Marchand 3772ca
+++ b/src/tracefs-events.c
Jerome Marchand 3772ca
@@ -922,7 +922,7 @@ char **tracefs_system_events(const char *tracing_dir, const char *system)
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
+			break;
Jerome Marchand 3772ca
 	}
Jerome Marchand 3772ca
 
Jerome Marchand 3772ca
 	closedir(dir);
Jerome Marchand 3772ca
-- 
Jerome Marchand 3772ca
2.45.2
Jerome Marchand 3772ca