blob: 8a2ae73fe0d26f5d6979690c9105043a7938ca31 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
|