perf top: Fix BPF support related crash with perf_event_paranoid=3 + kptr_restrict
authorJackie Liu <jackieliu2113@gmail.com>
Tue, 16 Mar 2021 01:24:53 +0000 (09:24 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 16 Mar 2021 13:01:44 +0000 (10:01 -0300)
commit1a096ae46e21b73f83a581e617f76326c1de592d
treecd4a31171223f24b643605bb7fc2194d86ea8b27
parente40647762fb5881360874e08e03e972d58d63c42
perf top: Fix BPF support related crash with perf_event_paranoid=3 + kptr_restrict

After installing the libelf-dev package and compiling perf, if we have
kptr_restrict=2 and perf_event_paranoid=3 'perf top' will crash because
the value of /proc/kallsyms cannot be obtained, which leads to
info->jited_ksyms == NULL. In order to solve this problem, Add a
check before use.

Also plug some leaks on the error path.

Suggested-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: jackie liu <liuyun01@kylinos.cn>
Link: http://lore.kernel.org/lkml/20210316012453.1156-1-liuyun01@kylinos.cn
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/bpf-event.c