From: Zhixing Chen <running910@gmail.com>
To: bpf@vger.kernel.org
Cc: Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
Zhixing Chen <running910@gmail.com>
Subject: [PATCH bpf-next] selftests/bpf: Guard link cleanup in fexit_bpf2bpf
Date: Thu, 17 Sep 2026 17:39:28 +0800 [thread overview]
Message-ID: <20260917093928.48495-1-running910@gmail.com> (raw)
test_fexit_bpf2bpf_common() can jump to the common cleanup path before
the link array is allocated, for example if bpf_prog_get_info_by_fd()
fails. The cleanup loop still indexes link[i] unconditionally, which can
dereference a NULL pointer and hide the original failure.
Guard the loop so the test reports the original failure instead.
Signed-off-by: Zhixing Chen <running910@gmail.com>
---
tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c b/tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c
index 6262c81cdaa9..d2f2dcc0f2e1 100644
--- a/tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c
+++ b/tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c
@@ -164,8 +164,10 @@ static void test_fexit_bpf2bpf_common(const char *obj_file,
goto close_prog;
close_prog:
- for (i = 0; i < prog_cnt; i++)
- bpf_link__destroy(link[i]);
+ if (link) {
+ for (i = 0; i < prog_cnt; i++)
+ bpf_link__destroy(link[i]);
+ }
bpf_object__close(obj);
bpf_object__close(tgt_obj);
free(link);
base-commit: 71b75648d1a21c0a6379741d00f41086ec95f14a
--
2.34.1
next reply other threads:[~2026-09-17 9:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 9:39 Zhixing Chen [this message]
2026-09-17 10:34 ` [PATCH bpf-next] selftests/bpf: Guard link cleanup in fexit_bpf2bpf bot+bpf-ci
2026-09-21 21:30 ` 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=20260917093928.48495-1-running910@gmail.com \
--to=running910@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
/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