[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191121144306.GG5078@kernel.org>
Date: Thu, 21 Nov 2019 11:43:06 -0300
From: Arnaldo Carvalho de Melo <arnaldo.melo@...il.com>
To: Hewenliang <hewenliang4@...wei.com>
Cc: rostedt@...dmis.org, acme@...hat.com, tstoyanov@...are.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] tools lib traceevent: Fix memory leakage in
copy_filter_type
Em Mon, Nov 18, 2019 at 08:44:15PM -0500, Hewenliang escreveu:
> It is necessary to free the memory that we have allocated when error occurs.
>
> Fixes: ef3072cd1d5c ("tools lib traceevent: Get rid of die in add_filter_type()")
> Signed-off-by: Hewenliang <hewenliang4@...wei.com>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@...dmis.org>
> Reviewed-by: Steven Rostedt (VMware) <rostedt@...dmis.org>
Thanks, applied.
- Arnaldo
> ---
> tools/lib/traceevent/parse-filter.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
> index 552592d153fb..f3cbf86e51ac 100644
> --- a/tools/lib/traceevent/parse-filter.c
> +++ b/tools/lib/traceevent/parse-filter.c
> @@ -1473,8 +1473,10 @@ static int copy_filter_type(struct tep_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 = TEP_FILTER_ARG_BOOLEAN;
> if (strcmp(str, "TRUE") == 0)
> @@ -1483,8 +1485,11 @@ static int copy_filter_type(struct tep_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;
>
> --
> 2.19.1
--
- Arnaldo
Powered by blists - more mailing lists