Skip to content

Commit

Permalink
selftests/bpf: fix crash in core_reloc when bpftool btfgen fails
Browse files Browse the repository at this point in the history
Initialize obj to null and skip closing if null.

Signed-off-by: Yucong Sun <fallentree@fb.com>
  • Loading branch information
thefallentree authored and Nobody committed Feb 17, 2022
1 parent adea906 commit cfee98d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tools/testing/selftests/bpf/prog_tests/core_reloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ static void run_core_reloc_tests(bool use_btfgen)
struct bpf_link *link = NULL;
struct bpf_map *data_map;
struct bpf_program *prog;
struct bpf_object *obj;
struct bpf_object *obj = NULL;
uint64_t my_pid_tgid;
struct data *data;
void *mmap_data = NULL;
Expand Down Expand Up @@ -992,7 +992,8 @@ static void run_core_reloc_tests(bool use_btfgen)
remove(btf_file);
bpf_link__destroy(link);
link = NULL;
bpf_object__close(obj);
if (obj)
bpf_object__close(obj);
}
}

Expand Down

0 comments on commit cfee98d

Please sign in to comment.