[PATCH 5.4 30/90] tools lib traceevent: Fix memory leakage in filter_event

From: Greg Kroah-Hartman
Date: Mon Feb 03 2020 - 11:34:58 EST


From: Hewenliang <hewenliang4@xxxxxxxxxx>

[ Upstream commit f84ae29a6169318f9c929720c49d96323d2bbab9 ]

It is necessary to call free_arg(arg) when add_filter_type() returns NULL
in filter_event().

Signed-off-by: Hewenliang <hewenliang4@xxxxxxxxxx>
Reviewed-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
Cc: Feilong Lin <linfeilong@xxxxxxxxxx>
Cc: Tzvetomir Stoyanov <tstoyanov@xxxxxxxxxx>
Link: http://lore.kernel.org/lkml/20191209063549.59941-1-hewenliang4@xxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
tools/lib/traceevent/parse-filter.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index f3cbf86e51acf..20eed719542e5 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -1228,8 +1228,10 @@ filter_event(struct tep_event_filter *filter, struct tep_event *event,
}

filter_type = add_filter_type(filter, event->id);
- if (filter_type == NULL)
+ if (filter_type == NULL) {
+ free_arg(arg);
return TEP_ERRNO__MEM_ALLOC_FAILED;
+ }

if (filter_type->filter)
free_arg(filter_type->filter);
--
2.20.1