diff options
author | CoprDistGit <infra@openeuler.org> | 2025-08-07 06:49:01 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2025-08-07 06:49:01 +0000 |
commit | 8765044a415eaa071b3bd4217b30057af8dcf5b7 (patch) | |
tree | 45835ec5a8f37c44c826c83ceb8ba0095b54598d /backport-fix-potential-NULL-dereference-in-print_rss_hkey.patch | |
parent | c2027a35dbf73cd104fac843c4cabb074d99f36d (diff) |
automatic import of ethtoolopeneuler22.03_LTS
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.patch | 42 |
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 + |