diff mbox series

[12/15] libtracefs: prevent memory leak in tracefs_dynevent_get_all()

Message ID 20240606153830.2666120-13-jmarchan@redhat.com (mailing list archive)
State Accepted
Commit f34fb1f29a89196afe3ce793a6395e1687a88a66
Headers show
Series libtracefs: fix misc issues found by static analysis | expand

Commit Message

Jerome Marchand June 6, 2024, 3:38 p.m. UTC
Free events in the error path of tracefs_dynevent_get_all().

Fixes a RESSOURCE_LEAK error (CWE-772)

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
---
 src/tracefs-dynevents.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/src/tracefs-dynevents.c b/src/tracefs-dynevents.c
index 7a3c45c..85c1fcd 100644
--- a/src/tracefs-dynevents.c
+++ b/src/tracefs-dynevents.c
@@ -589,6 +589,7 @@  tracefs_dynevent_get_all(unsigned int types, const char *system)
 	return all_events;
 
 error:
+	free(events);
 	if (all_events) {
 		for (i = 0; i < all; i++)
 			free(all_events[i]);