lkml.org 
[lkml]   [2019]   [Jul]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v1 02/11] perf stat: Smatch: Fix use-after-freed pointer
Em Tue, Jul 02, 2019 at 06:34:11PM +0800, Leo Yan escreveu:
> Based on the following report from Smatch, fix the use-after-freed
> pointer.
>
> tools/perf/builtin-stat.c:1353
> add_default_attributes() warn: passing freed memory 'str'.
>
> The pointer 'str' has been freed but later it is still passed into the
> function parse_events_print_error(). This patch fixes this
> use-after-freed issue.

thanks, applied.

> Signed-off-by: Leo Yan <leo.yan@linaro.org>
> ---
> tools/perf/builtin-stat.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index 8a35fc5a7281..de0f6d0e96a2 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -1349,8 +1349,8 @@ static int add_default_attributes(void)
> fprintf(stderr,
> "Cannot set up top down events %s: %d\n",
> str, err);
> - free(str);
> parse_events_print_error(&errinfo, str);
> + free(str);
> return -1;
> }
> } else {
> --
> 2.17.1

--

- Arnaldo

\
 
 \ /
  Last update: 2019-07-03 20:19    [W:0.121 / U:1.236 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site