Skip to content

Commit 4c17736

Browse files
Casey Chennamhyung
authored andcommitted
perf tool: fix dereferencing NULL al->maps
With 0dd5041 ("perf addr_location: Add init/exit/copy functions"), when cpumode is 3 (macro PERF_RECORD_MISC_HYPERVISOR), thread__find_map() could return with al->maps being NULL. The path below could add a callchain_cursor_node with NULL ms.maps. add_callchain_ip() thread__find_symbol(.., &al) thread__find_map(.., &al) // al->maps becomes NULL ms.maps = maps__get(al.maps) callchain_cursor_append(..., &ms, ...) node->ms.maps = maps__get(ms->maps) Then the path below would dereference NULL maps and get segfault. fill_callchain_info() maps__machine(node->ms.maps); Fix it by checking if maps is NULL in fill_callchain_info(). Fixes: 0dd5041 ("perf addr_location: Add init/exit/copy functions") Signed-off-by: Casey Chen <[email protected]> Reviewed-by: Ian Rogers <[email protected]> Reviewed-by: Arnaldo Carvalho de Melo <[email protected]> Acked-by: Namhyung Kim <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 92717bc commit 4c17736

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/perf/util/callchain.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ int hist_entry__append_callchain(struct hist_entry *he, struct perf_sample *samp
11411141
int fill_callchain_info(struct addr_location *al, struct callchain_cursor_node *node,
11421142
bool hide_unresolved)
11431143
{
1144-
struct machine *machine = maps__machine(node->ms.maps);
1144+
struct machine *machine = node->ms.maps ? maps__machine(node->ms.maps) : NULL;
11451145

11461146
maps__put(al->maps);
11471147
al->maps = maps__get(node->ms.maps);

0 commit comments

Comments
 (0)