diff options
author | Yuntao Wang <ytcoode@gmail.com> | 2022-04-08 12:14:52 +0800 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2022-04-08 22:38:17 +0200 |
commit | 658d87687cd5a6c8762d1de8abee1e6792d8d71e (patch) | |
tree | f8e4b4ae42548cec1a14f8c8efd30046203a84c2 /tools | |
parent | 8555defe48610a7efe9f2d72689e2d4f006898d7 (diff) | |
download | linux-658d87687cd5a6c8762d1de8abee1e6792d8d71e.tar.bz2 |
selftests/bpf: Fix return value checks in perf_event_stackmap test
The bpf_get_stackid() function may also return 0 on success as per UAPI BPF
helper documentation. Therefore, correct checks from 'val > 0' to 'val >= 0'
to ensure that they cover all possible success return values.
Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20220408041452.933944-1-ytcoode@gmail.com
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/bpf/progs/perf_event_stackmap.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/testing/selftests/bpf/progs/perf_event_stackmap.c b/tools/testing/selftests/bpf/progs/perf_event_stackmap.c index b3fcb5274ee0..f793280a3238 100644 --- a/tools/testing/selftests/bpf/progs/perf_event_stackmap.c +++ b/tools/testing/selftests/bpf/progs/perf_event_stackmap.c @@ -35,10 +35,10 @@ int oncpu(void *ctx) long val; val = bpf_get_stackid(ctx, &stackmap, 0); - if (val > 0) + if (val >= 0) stackid_kernel = 2; val = bpf_get_stackid(ctx, &stackmap, BPF_F_USER_STACK); - if (val > 0) + if (val >= 0) stackid_user = 2; trace = bpf_map_lookup_elem(&stackdata_map, &key); |