summaryrefslogtreecommitdiff
path: root/backport-fix-possible-NULL-dereference-in-fec_mode_walk.patch
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2025-08-07 06:49:01 +0000
committerCoprDistGit <infra@openeuler.org>2025-08-07 06:49:01 +0000
commit8765044a415eaa071b3bd4217b30057af8dcf5b7 (patch)
tree45835ec5a8f37c44c826c83ceb8ba0095b54598d /backport-fix-possible-NULL-dereference-in-fec_mode_walk.patch
parentc2027a35dbf73cd104fac843c4cabb074d99f36d (diff)
automatic import of ethtoolopeneuler22.03_LTS
Diffstat (limited to 'backport-fix-possible-NULL-dereference-in-fec_mode_walk.patch')
-rw-r--r--backport-fix-possible-NULL-dereference-in-fec_mode_walk.patch39
1 files changed, 39 insertions, 0 deletions
diff --git a/backport-fix-possible-NULL-dereference-in-fec_mode_walk.patch b/backport-fix-possible-NULL-dereference-in-fec_mode_walk.patch
new file mode 100644
index 0000000..dc3f4f7
--- /dev/null
+++ b/backport-fix-possible-NULL-dereference-in-fec_mode_walk.patch
@@ -0,0 +1,39 @@
+From 33fffbbdc12d71b3bb23acd04b97ce1b485f3c60 Mon Sep 17 00:00:00 2001
+From: AntonMoryakov <ant.v.moryakov@gmail.com>
+Date: Sun, 18 May 2025 16:18:18 +0300
+Subject: fec: fix possible NULL dereference in fec_mode_walk()
+
+Static analyzer (Svace) reported a possible null pointer dereference
+in fec_mode_walk(), where the 'name' pointer is passed to print_string()
+without checking for NULL.
+
+Although some callers check the return value of get_string(), others
+(e.g., walk_bitset()) do not. This patch adds an early NULL check
+to avoid dereferencing a null pointer.
+
+This resolves:
+DEREF_OF_NULL.EX.COND: json_print.c:142 via fec.c
+
+Found by Svace static analysis tool.
+
+Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
+---
+ netlink/fec.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/netlink/fec.c b/netlink/fec.c
+index 6027dc0..ed100d7 100644
+--- a/netlink/fec.c
++++ b/netlink/fec.c
+@@ -27,6 +27,8 @@ fec_mode_walk(unsigned int idx, const char *name, bool val, void *data)
+
+ if (!val)
+ return;
++ if (!name)
++ return;
+ if (empty)
+ *empty = false;
+
+--
+2.23.0
+