diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-08-01 17:49:13 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-08-01 17:49:13 -0400 |
commit | c17c17e8c26a5d44b3a8a6ef8c55233d72eed6c0 (patch) | |
tree | e41f5b657afcb37c03e1ee03873d30b3d130786b /tools | |
parent | ee51d851392e1fe3e8be30b3c5847f34da343424 (diff) |
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 <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Fixes: ee205503f233 ("perf tools: Fix annotation with kcore")
Link: http://lkml.kernel.org/n/tip-qi4rpjq8yo6myvg99kkgt0xz@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/annotate.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 4982ed487e96..4024d309bb00 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -1185,9 +1185,8 @@ int symbol__disassemble(struct symbol *sym, struct map *map, size_t privsize) | |||
1185 | if (dso->has_build_id) | 1185 | if (dso->has_build_id) |
1186 | return ENOMEM; | 1186 | return ENOMEM; |
1187 | goto fallback; | 1187 | goto fallback; |
1188 | } else if (dso__is_kcore(dso)) { | 1188 | } else if (dso__is_kcore(dso) || |
1189 | goto fallback; | 1189 | readlink(symfs_filename, command, sizeof(command)) < 0 || |
1190 | } else if (readlink(symfs_filename, command, sizeof(command)) < 0 || | ||
1191 | strstr(command, DSO__NAME_KALLSYMS) || | 1190 | strstr(command, DSO__NAME_KALLSYMS) || |
1192 | access(symfs_filename, R_OK)) { | 1191 | access(symfs_filename, R_OK)) { |
1193 | free(filename); | 1192 | free(filename); |