From f111e854d99e3284893ef59efcfb6e5a5857d396 Mon Sep 17 00:00:00 2001 From: AntonMoryakov 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 --- 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