Skip to content

Commit cfee98d

Browse files
Yucong SunNobody
Yucong Sun
authored and
Nobody
committed
selftests/bpf: fix crash in core_reloc when bpftool btfgen fails
Initialize obj to null and skip closing if null. Signed-off-by: Yucong Sun <[email protected]>
1 parent adea906 commit cfee98d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ static void run_core_reloc_tests(bool use_btfgen)
861861
struct bpf_link *link = NULL;
862862
struct bpf_map *data_map;
863863
struct bpf_program *prog;
864-
struct bpf_object *obj;
864+
struct bpf_object *obj = NULL;
865865
uint64_t my_pid_tgid;
866866
struct data *data;
867867
void *mmap_data = NULL;
@@ -992,7 +992,8 @@ static void run_core_reloc_tests(bool use_btfgen)
992992
remove(btf_file);
993993
bpf_link__destroy(link);
994994
link = NULL;
995-
bpf_object__close(obj);
995+
if (obj)
996+
bpf_object__close(obj);
996997
}
997998
}
998999

0 commit comments

Comments
 (0)