[PATCH 13/15] libtracefs: close dir in the error path in tracefs_system_events()

"Jerome Marchand" <[email protected]>
Newsgroups org.kernel.vger.linux-trace-devel
Message-ID <[email protected]>
In tracefs_system_events(), we don't close dir if add_list_string()
fails. At this point, just breaking out of the loop fixes that.

Fixes a RESSOURCE_LEAK error (CWE-772)

Signed-off-by: Jerome Marchand <[email protected]>
---
 src/tracefs-events.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/tracefs-events.c b/src/tracefs-events.c
index 88325e1..1fa3f2f 100644
--- a/src/tracefs-events.c
+++ b/src/tracefs-events.c
@@ -922,7 +922,7 @@ char **tracefs_system_events(const char *tracing_dir, const char *system)
 		free(event);
 
 		if (add_list_string(&events, name) < 0)
-			goto out_free;
+			break;
 	}
 
 	closedir(dir);
-- 
2.44.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.