diff options
| author | Hao Luo <[email protected]> | 2020-09-03 20:05:28 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <[email protected]> | 2020-09-04 00:33:31 +0000 |
| commit | 95cec14b0308085c028c4d4fb3d09fad3902b4c3 (patch) | |
| tree | 84f648ba51fa70be277215e72b2113c532f319d4 /tools/testing/selftests/bpf/prog_tests/global_data_init.c | |
| parent | Merge branch 'libbpf-support-bpf-to-bpf-calls' (diff) | |
| download | kernel-95cec14b0308085c028c4d4fb3d09fad3902b4c3.tar.gz kernel-95cec14b0308085c028c4d4fb3d09fad3902b4c3.zip | |
selftests/bpf: Fix check in global_data_init.
The returned value of bpf_object__open_file() should be checked with
libbpf_get_error() rather than NULL. This fix prevents test_progs from
crash when test_global_data.o is not present.
Signed-off-by: Hao Luo <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/global_data_init.c')
| -rw-r--r-- | tools/testing/selftests/bpf/prog_tests/global_data_init.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/global_data_init.c b/tools/testing/selftests/bpf/prog_tests/global_data_init.c index 3bdaa5a40744..ee46b11f1f9a 100644 --- a/tools/testing/selftests/bpf/prog_tests/global_data_init.c +++ b/tools/testing/selftests/bpf/prog_tests/global_data_init.c @@ -12,7 +12,8 @@ void test_global_data_init(void) size_t sz; obj = bpf_object__open_file(file, NULL); - if (CHECK_FAIL(!obj)) + err = libbpf_get_error(obj); + if (CHECK_FAIL(err)) return; map = bpf_object__find_map_by_name(obj, "test_glo.rodata"); |
