libtracefs: Close dir in the error path in tracefs_event_systems()
In tracefs_event_systems, 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)
Link: https://lore.kernel.org/linux-trace-devel/20240606153830.2666120-15-jmarchan@redhat.com
Fixes: 056a177e1d686 ("libtracefs: Restructure how string lists work")
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
diff --git a/src/tracefs-events.c b/src/tracefs-events.c
index 1fa3f2f..83069aa 100644
--- a/src/tracefs-events.c
+++ b/src/tracefs-events.c
@@ -858,7 +858,7 @@
free(sys);
if (ret >= 0) {
if (add_list_string(&systems, name) < 0)
- goto out_free;
+ break;
}
}