summaryrefslogtreecommitdiff
path: root/backport-fix-potential-NULL-dereference-in-print_rss_hkey.patch
diff options
context:
space:
mode:
Diffstat (limited to 'backport-fix-potential-NULL-dereference-in-print_rss_hkey.patch')
-rw-r--r--backport-fix-potential-NULL-dereference-in-print_rss_hkey.patch42
1 files changed, 42 insertions, 0 deletions
diff --git a/backport-fix-potential-NULL-dereference-in-print_rss_hkey.patch b/backport-fix-potential-NULL-dereference-in-print_rss_hkey.patch
new file mode 100644
index 0000000..8a2ae73
--- /dev/null
+++ b/backport-fix-potential-NULL-dereference-in-print_rss_hkey.patch
@@ -0,0 +1,42 @@
+From f111e854d99e3284893ef59efcfb6e5a5857d396 Mon Sep 17 00:00:00 2001
+From: AntonMoryakov <ant.v.moryakov@gmail.com>
+Date: Sun, 18 May 2025 16:08:28 +0300
+Subject: common: fix potential NULL dereference in print_rss_hkey()
+
+Static analyzer (Svace) reported a possible null pointer dereference
+in print_rss_hkey(). Specifically, when the 'hkey' pointer is NULL,
+the function continues execution after printing an error message,
+leading to dereferencing hkey[i].
+
+This patch adds an early return after the NULL check to prevent
+execution from continuing in such cases.
+
+This resolves:
+DEREF_AFTER_NULL: common.c:209
+
+Found by Svace static analysis tool.
+
+Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
+---
+ common.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/common.c b/common.c
+index b8fd4d5..86b6a93 100644
+--- a/common.c
++++ b/common.c
+@@ -199,8 +199,10 @@ void print_rss_hkey(u8 *hkey, u32 hkey_size)
+ u32 i;
+
+ printf("RSS hash key:\n");
+- if (!hkey_size || !hkey)
++ if (!hkey_size || !hkey) {
+ printf("Operation not supported\n");
++ return;
++ }
+
+ for (i = 0; i < hkey_size; i++) {
+ if (i == (hkey_size - 1))
+--
+2.23.0
+