From: Prabhav Kumar Vaish <pvkumar5749404@gmail.com>
To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org,
yonghong.song@linux.dev, john.fastabend@gmail.com,
kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com,
jolsa@kernel.org, mykolal@fb.com, shuah@kernel.org
Cc: Prabhav Kumar Vaish <pvkumar5749404@gmail.com>,
bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] selftests/bpf: Fix null pointer check in skb_pkt_end.c
Date: Tue, 22 Apr 2025 23:53:31 +0530 [thread overview]
Message-ID: <20250422182331.1188338-1-pvkumar5749404@gmail.com> (raw)
Ensure that 'tcp' is checked for NULL before dereferencing. This resolves
a potential null pointer dereference warning reported by static analysis.
Signed-off-by: Prabhav Kumar Vaish <pvkumar5749404@gmail.com>
---
tools/testing/selftests/bpf/progs/skb_pkt_end.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/progs/skb_pkt_end.c b/tools/testing/selftests/bpf/progs/skb_pkt_end.c
index 3bb4451524a1..db33ff2839f7 100644
--- a/tools/testing/selftests/bpf/progs/skb_pkt_end.c
+++ b/tools/testing/selftests/bpf/progs/skb_pkt_end.c
@@ -45,10 +45,10 @@ int main_prog(struct __sk_buff *skb)
goto out;
tcp = (void*)(ip + 1);
- if (tcp->dest != 0)
- goto out;
if (!tcp)
goto out;
+ if (tcp->dest != 0)
+ goto out;
urg_ptr = tcp->urg_ptr;
--
2.34.1
next reply other threads:[~2025-04-22 18:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-22 18:23 Prabhav Kumar Vaish [this message]
2025-04-22 22:15 ` Martin KaFai Lau
2025-04-23 17:58 ` [PATCH] selftests/bpf: Fix potential null pointer dereference " Prabhav Kumar Vaish
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=20250422182331.1188338-1-pvkumar5749404@gmail.com \
--to=pvkumar5749404@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@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
all inboxes | Powered by JetHome®