[ovs-dev] [PATCH 09/11] tnl-neigh-cache: Fix possible null pointer.

William Tu u9012063 at gmail.com
Sat Oct 28 17:31:56 UTC 2017


Clang reports possible null pointer '&wc->masks.ipv6_src' to memset.
Workaround it by adding extra pointer check.

Signed-off-by: William Tu <u9012063 at gmail.com>
---
 lib/tnl-neigh-cache.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/tnl-neigh-cache.c b/lib/tnl-neigh-cache.c
index a28ce1de8855..b3024848b8d5 100644
--- a/lib/tnl-neigh-cache.c
+++ b/lib/tnl-neigh-cache.c
@@ -178,6 +178,9 @@ tnl_nd_snoop(const struct flow *flow, struct flow_wildcards *wc,
         return EINVAL;
     }
 
+    if (OVS_UNLIKELY(!wc))
+        return EINVAL;
+
     memset(&wc->masks.ipv6_src, 0xff, sizeof wc->masks.ipv6_src);
     memset(&wc->masks.ipv6_dst, 0xff, sizeof wc->masks.ipv6_dst);
     memset(&wc->masks.nd_target, 0xff, sizeof wc->masks.nd_target);
-- 
2.7.4



More information about the dev mailing list