diff options
author | Ingo Molnar <mingo@kernel.org> | 2017-10-28 16:16:11 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-10-28 16:16:11 +0200 |
commit | 4139433c9a81a6ee21e5293989122c203a14a6d8 (patch) | |
tree | eec3b757537a16c0d538125dacae3b26733162ce /tools/perf/util/annotate.c | |
parent | 11224e1fc40a6556dc285573ea93dd522f8c563f (diff) | |
parent | 9445464bb8318e42e5232b37fc7218ed028517f6 (diff) |
Merge tag 'perf-urgent-for-mingo-4.14-20171027' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/urgent fixes from Arnaldo Carvalho de Melo:
- Fix memory corruption in the annotation routines because of zero
length symbols (asm ones) (Ravi Bangoria)
- Fix printing garbage as an error message when re-running the
lexer events matcher (Jiri Olsa)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r-- | tools/perf/util/annotate.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 4397a8b6e6cd..aa66791b1bfc 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -606,9 +606,19 @@ static struct arch *arch__find(const char *name) int symbol__alloc_hist(struct symbol *sym) { struct annotation *notes = symbol__annotation(sym); - const size_t size = symbol__size(sym); + size_t size = symbol__size(sym); size_t sizeof_sym_hist; + /* + * Add buffer of one element for zero length symbol. + * When sample is taken from first instruction of + * zero length symbol, perf still resolves it and + * shows symbol name in perf report and allows to + * annotate it. + */ + if (size == 0) + size = 1; + /* Check for overflow when calculating sizeof_sym_hist */ if (size > (SIZE_MAX - sizeof(struct sym_hist)) / sizeof(struct sym_hist_entry)) return -1; |