From f34fb1f29a89196afe3ce793a6395e1687a88a66 Mon Sep 17 00:00:00 2001 From: Jerome Marchand Date: Thu, 6 Jun 2024 17:38:26 +0200 Subject: [PATCH 12/15] libtracefs: Prevent memory leak in tracefs_dynevent_get_all() Free events in the error path of tracefs_dynevent_get_all(). Fixes a RESSOURCE_LEAK error (CWE-772) Link: https://lore.kernel.org/linux-trace-devel/20240606153830.2666120-13-jmarchan@redhat.com Fixes: b04f18b005c6b ("libtracefs: New APIs for dynamic events") Signed-off-by: Jerome Marchand Signed-off-by: Steven Rostedt (Google) --- src/tracefs-dynevents.c | 1 + 1 file changed, 1 insertion(+) 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]); -- 2.45.2