diff options
author | Namhyung Kim <namhyung@kernel.org> | 2017-10-31 05:06:53 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-11-01 17:43:56 +0300 |
commit | b7b75a60b291cc699ca9bb2a8517a1b3b08bbeb1 (patch) | |
tree | ce1473a3d4e86e261e457eb05a36647d88f50686 /tools/perf/util/srcline.c | |
parent | 1de3038d0082a1c2edd7a7b1b3381e38f42af0e7 (diff) | |
download | linux-b7b75a60b291cc699ca9bb2a8517a1b3b08bbeb1.tar.xz |
perf srcline: Fix memory leak in addr2inlines()
When libbfd is not used, addr2inlines() executes `addr2line -i` and
process output line by line. But it resets filename to NULL in the loop
so getline() allocates additional memory everytime instead of realloc.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: kernel-team@lge.com
Link: http://lkml.kernel.org/r/20171031020654.31163-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/srcline.c')
-rw-r--r-- | tools/perf/util/srcline.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c index c143c3bc1ef8..51dc49c65476 100644 --- a/tools/perf/util/srcline.c +++ b/tools/perf/util/srcline.c @@ -456,20 +456,17 @@ static struct inline_node *addr2inlines(const char *dso_name, u64 addr, while (getline(&filename, &len, fp) != -1) { char *srcline; - if (filename_split(filename, &line_nr) != 1) { - free(filename); + if (filename_split(filename, &line_nr) != 1) goto out; - } srcline = srcline_from_fileline(filename, line_nr); if (inline_list__append(sym, srcline, node) != 0) goto out; - - filename = NULL; } out: pclose(fp); + free(filename); return node; } |