BPF List
 help / color / mirror / Atom feed
From: Yucong Sun <fallentree@fb.com>
To: <bpf@vger.kernel.org>
Cc: <andrii@kernel.org>, <fallentree@fb.com>, <sunyucong@gmail.com>
Subject: [PATCH bpf-next] selftests/bpf: fix crash in core_reloc when bpftool btfgen fails
Date: Thu, 17 Feb 2022 10:02:10 -0800	[thread overview]
Message-ID: <20220217180210.2981502-1-fallentree@fb.com> (raw)

Initialize obj to null and skip closing if null.

Signed-off-by: Yucong Sun <fallentree@fb.com>
---
 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


             reply	other threads:[~2022-02-17 18:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-17 18:02 Yucong Sun [this message]
2022-02-17 18:32 ` [PATCH bpf-next] selftests/bpf: fix crash in core_reloc when bpftool btfgen fails Martin KaFai Lau
2022-02-17 18:55   ` sunyucong
2022-02-17 18:57     ` Andrii Nakryiko
2022-02-17 19:07       ` Andrii Nakryiko
2022-02-17 19:10 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220217180210.2981502-1-fallentree@fb.com \
    --to=fallentree@fb.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sunyucong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox