diff options
author | Daniel T. Lee <danieltimlee@gmail.com> | 2019-04-04 00:17:56 +0200 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2019-04-04 16:43:47 +0200 |
commit | e67b2c715415b121339049b630f0b4e1ede888dc (patch) | |
tree | ead14552f2199aca864d04cdff0afcd23222eaf9 /samples/bpf/trace_event_user.c | |
parent | selftests/bpf: ksym_search won't check symbols exists (diff) | |
download | linux-e67b2c715415b121339049b630f0b4e1ede888dc.tar.xz linux-e67b2c715415b121339049b630f0b4e1ede888dc.zip |
samples, selftests/bpf: add NULL check for ksym_search
Since, ksym_search added with verification logic for symbols existence,
it could return NULL when the kernel symbols are not loaded.
This commit will add NULL check logic after ksym_search.
Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'samples/bpf/trace_event_user.c')
-rw-r--r-- | samples/bpf/trace_event_user.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/samples/bpf/trace_event_user.c b/samples/bpf/trace_event_user.c index d08046ab81f0..d4178f60e075 100644 --- a/samples/bpf/trace_event_user.c +++ b/samples/bpf/trace_event_user.c @@ -34,6 +34,11 @@ static void print_ksym(__u64 addr) if (!addr) return; sym = ksym_search(addr); + if (!sym) { + printf("ksym not found. Is kallsyms loaded?\n"); + return; + } + printf("%s;", sym->name); if (!strcmp(sym->name, "sys_read")) sys_read_seen = true; |