Skip to content
Commit 4c177366 authored by Casey Chen's avatar Casey Chen Committed by Namhyung Kim
Browse files

perf tool: fix dereferencing NULL al->maps

With 0dd5041c ("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: 0dd5041c

 ("perf addr_location: Add init/exit/copy functions")
Signed-off-by: default avatarCasey Chen <cachen@purestorage.com>
Reviewed-by: default avatarIan Rogers <irogers@google.com>
Reviewed-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: yzhong@purestorage.com
Link: https://lore.kernel.org/r/20240722211548.61455-1-cachen@purestorage.com
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
parent 92717bc0
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment