Commit 1c1ff961 authored by Hewenliang's avatar Hewenliang Committed by Kleber Sacilotto de Souza

libtraceevent: Fix memory leakage in copy_filter_type

BugLink: https://bugs.launchpad.net/bugs/1858462

[ Upstream commit 10992af6 ]

It is necessary to free the memory that we have allocated when error occurs.

Fixes: ef3072cd ("tools lib traceevent: Get rid of die in add_filter_type()")
Signed-off-by: default avatarHewenliang <hewenliang4@huawei.com>
Reviewed-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Link: http://lore.kernel.org/lkml/20191119014415.57210-1-hewenliang4@huawei.comSigned-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent c0f3458d
......@@ -1484,8 +1484,10 @@ static int copy_filter_type(struct event_filter *filter,
if (strcmp(str, "TRUE") == 0 || strcmp(str, "FALSE") == 0) {
/* Add trivial event */
arg = allocate_arg();
if (arg == NULL)
if (arg == NULL) {
free(str);
return -1;
}
arg->type = FILTER_ARG_BOOLEAN;
if (strcmp(str, "TRUE") == 0)
......@@ -1494,8 +1496,11 @@ static int copy_filter_type(struct event_filter *filter,
arg->boolean.value = 0;
filter_type = add_filter_type(filter, event->id);
if (filter_type == NULL)
if (filter_type == NULL) {
free(str);
free_arg(arg);
return -1;
}
filter_type->filter = arg;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment