Skip to content

Commit 95cec14

Browse files
haoluo1022Alexei Starovoitov
authored and
Alexei Starovoitov
committed
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]
1 parent b4ff7ad commit 95cec14

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/testing/selftests/bpf/prog_tests/global_data_init.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ void test_global_data_init(void)
1212
size_t sz;
1313

1414
obj = bpf_object__open_file(file, NULL);
15-
if (CHECK_FAIL(!obj))
15+
err = libbpf_get_error(obj);
16+
if (CHECK_FAIL(err))
1617
return;
1718

1819
map = bpf_object__find_map_by_name(obj, "test_glo.rodata");

0 commit comments

Comments
 (0)