[ovs-dev] [PATCH 07/11] packets: Fix possible null pointer to memcmp.

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


Clang reports possible null pointer passes to dst of memcmp, &nh->ip6_src.
This is due to *nh comes from dp_packet_l3, and dp_packet_l3 might
return NULL.  Fix it by adding ovs_assert check.

Signed-off-by: William Tu <u9012063 at gmail.com>
---
 lib/packets.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/packets.c b/lib/packets.c
index 230a62553ff6..7b147bbfb880 100644
--- a/lib/packets.c
+++ b/lib/packets.c
@@ -1191,6 +1191,7 @@ packet_set_ipv6(struct dp_packet *packet, const struct in6_addr *src,
 
     rh_present = packet_rh_present(packet, &proto);
 
+    ovs_assert(&nh->ip6_src);
     if (memcmp(&nh->ip6_src, src, sizeof(ovs_be32[4]))) {
         packet_set_ipv6_addr(packet, proto, nh->ip6_src.be32, src, true);
     }
-- 
2.7.4



More information about the dev mailing list