summaryrefslogtreecommitdiff
path: root/samples/bpf/offwaketime_user.c
diff options
context:
space:
mode:
authorDaniel T. Lee <danieltimlee@gmail.com>2019-04-04 01:17:56 +0300
committerDaniel Borkmann <daniel@iogearbox.net>2019-04-04 17:43:47 +0300
commite67b2c715415b121339049b630f0b4e1ede888dc (patch)
treeead14552f2199aca864d04cdff0afcd23222eaf9 /samples/bpf/offwaketime_user.c
parent0979ff7992fb6f4eb837995b12f4071dcafebd2d (diff)
downloadlinux-e67b2c715415b121339049b630f0b4e1ede888dc.tar.xz
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/offwaketime_user.c')
-rw-r--r--samples/bpf/offwaketime_user.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/samples/bpf/offwaketime_user.c b/samples/bpf/offwaketime_user.c
index f06063af9fcb..bb315ce1b866 100644
--- a/samples/bpf/offwaketime_user.c
+++ b/samples/bpf/offwaketime_user.c
@@ -28,6 +28,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;
+ }
+
if (PRINT_RAW_ADDR)
printf("%s/%llx;", sym->name, addr);
else