The gcc static analyzer pointed out a potential NULL pointer
dereference in route_table_parse().

While the probability is low, let's plug it.

Fixes: 0b8da9ae1f38 ("route: support IPv6 and use IPv4-mapped addresses")
Fixes: 71785737ded2 ("route-table: Split header and attribute parsing.")
Signed-off-by: Frode Nordahl <[email protected]>
---
 lib/route-table.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/route-table.c b/lib/route-table.c
index 8106dc93d..fbda4c41d 100644
--- a/lib/route-table.c
+++ b/lib/route-table.c
@@ -469,6 +469,10 @@ route_table_parse(struct ofpbuf *buf, void *change)
     nlmsg = ofpbuf_at(buf, 0, NLMSG_HDRLEN);
     rtm = ofpbuf_at(buf, NLMSG_HDRLEN, sizeof *rtm);
 
+    if (!nlmsg || !rtm) {
+        return 0;
+    }
+
     return route_table_parse__(buf, NLMSG_HDRLEN + sizeof *rtm,
                                nlmsg, rtm, NULL, change);
 }
-- 
2.43.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to