Blob Blame History Raw
From 03551ebce2a745127a9b6cf3765381c05621b27a Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Fri, 7 Jun 2024 18:05:40 +0200
Subject: [PATCH 4/7] libtraceevent: Prevent a memory leak in process_fields()

One of the error paths after the field was allocated goes to the wrong
label.  Go to out_free_field if the allocation of arg fails.

Fixes a RESOURCE_LEAK error (CWE-772)

Link: https://lore.kernel.org/linux-trace-devel/20240607160542.46152-3-jmarchan@redhat.com

Fixes: b17b75e511722 ("tools lib traceevent: Handle alloc_arg failure")
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 src/event-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/event-parse.c b/src/event-parse.c
index b625621..9f0522c 100644
--- a/src/event-parse.c
+++ b/src/event-parse.c
@@ -2963,7 +2963,7 @@ process_fields(struct tep_event *event, struct tep_print_flag_sym **list, char *
 		free_arg(arg);
 		arg = alloc_arg();
 		if (!arg)
-			goto out_free;
+			goto out_free_field;
 
 		free_token(token);
 		type = process_arg(event, arg, &token);
-- 
2.45.2