perf annotate: Plug filename string leak
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: c17c17e8c26a5d44b3a8a6ef8c55233d72eed6c0 Gitweb: http://git.kernel.org/tip/c17c17e8c26a5d44b3a8a6ef8c55233d72eed6c0 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Mon, 1 Aug 2016 18:49:13 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 1 Aug 2016 18:49:13 -0300
perf annotate: Plug filename string leak
If dso__build_id_filename(..., NULL, ...) returns !NULL its because it allocated it, so, when reaching the 'if (dso__is_kcore()) test, we already checked that and were just "fallbacking" to using dso->long_name, but without freeing filename, thus leaking it.
Fix it by adding the dso__is_kcore() test to the 'or' group just after it, the one containing the full fallback code, including freeing the filename.
Cc Adrian Hunter <[email protected]>
Cc David Ahern <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Wang Nan <[email protected]>
Fixes ee205503f233 ("perf tools: Fix annotation with kcore")
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/util/annotate.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
tools/perf/util/annotate.c +2 -3
@@ -1185,9 +1185,8 @@ int symbol__disassemble(struct symbol *sym, struct map *map, size_t privsize)if (dso->has_build_id)return ENOMEM ; goto fallback; - }else if (dso__is_kcore (dso)) { - goto fallback; - }else if (readlink (symfs_filename, command,sizeof (command)) <0 || + }else if (dso__is_kcore (dso) || +readlink (symfs_filename, command,sizeof (command)) <0 ||strstr (command,DSO__NAME_KALLSYMS ) ||access (symfs_filename,R_OK )) {free (filename);