mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 09:31:14 +00:00
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>
This commit is contained in:
parent
1de3038d00
commit
b7b75a60b2
1 changed files with 2 additions and 5 deletions
|
@ -456,20 +456,17 @@ static struct inline_node *addr2inlines(const char *dso_name, u64 addr,
|
||||||
while (getline(&filename, &len, fp) != -1) {
|
while (getline(&filename, &len, fp) != -1) {
|
||||||
char *srcline;
|
char *srcline;
|
||||||
|
|
||||||
if (filename_split(filename, &line_nr) != 1) {
|
if (filename_split(filename, &line_nr) != 1)
|
||||||
free(filename);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
srcline = srcline_from_fileline(filename, line_nr);
|
srcline = srcline_from_fileline(filename, line_nr);
|
||||||
if (inline_list__append(sym, srcline, node) != 0)
|
if (inline_list__append(sym, srcline, node) != 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
filename = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
pclose(fp);
|
pclose(fp);
|
||||||
|
free(filename);
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue