[PATCH bpf-next] selftests/bpf: fix crash in core_reloc when bpftool btfgen fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Initialize obj to null and skip closing if null.

Signed-off-by: Yucong Sun <fallentree@xxxxxx>
---
 tools/testing/selftests/bpf/prog_tests/core_reloc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/core_reloc.c b/tools/testing/selftests/bpf/prog_tests/core_reloc.c
index baf53c23c08d..7211243a22c3 100644
--- a/tools/testing/selftests/bpf/prog_tests/core_reloc.c
+++ b/tools/testing/selftests/bpf/prog_tests/core_reloc.c
@@ -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;
@@ -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);
 	}
 }
 
-- 
2.30.2





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux