Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf annotate: Fix 's' on source line when disasm is empty

If the disasm is empty, 's' should fail. Instead it seemingly works,
hiding the empty lines and causing an assertion error on the next time
annotate is called (from within perf report).

The problem is caused by a buffer overflow, caused by a wrong exit
condition in annotate_browser__find_next_asm_line, which checks
browser->b.top instead of browser->b.entries.

This patch fixes the issue, making annotate_browser__toggle_source
fail if the disasm is empty (nothing happens to the user).

Fixes: 6de249d66d2e7881 ("perf annotate: Allow 's' on source code lines")
Signed-off-by: Riccardo Mancini <rickyman7@gmail.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Martin Liška <mliska@suse.cz>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20210705161524.72953-1-rickyman7@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Riccardo Mancini and committed by
Arnaldo Carvalho de Melo
5a4451e4 d5882a92

+2 -2
+2 -2
tools/perf/ui/browsers/annotate.c
··· 350 350 struct annotation_line *it = al; 351 351 352 352 /* find next asm line */ 353 - list_for_each_entry_continue(it, browser->b.top, node) { 353 + list_for_each_entry_continue(it, browser->b.entries, node) { 354 354 if (it->idx_asm >= 0) 355 355 return it; 356 356 } 357 357 358 358 /* no asm line found forwards, try backwards */ 359 359 it = al; 360 - list_for_each_entry_continue_reverse(it, browser->b.top, node) { 360 + list_for_each_entry_continue_reverse(it, browser->b.entries, node) { 361 361 if (it->idx_asm >= 0) 362 362 return it; 363 363 }