]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Fix some nhg SA issues found in latest Coverity
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 29 Oct 2019 00:30:06 +0000 (20:30 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 29 Oct 2019 00:30:06 +0000 (20:30 -0400)
Fix 2 Coverity issues:
1) zebra_nhg.c -> all paths in nhg_ctx_process_finish have
already deref'ed the ctx pointer no need for a test of it

2) the **ifp pointer passed in may be NULL.  Prevent an accidental
deref if calling function does not pass in a ifp pointer.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
zebra/rt_netlink.c
zebra/zebra_nhg.c

index 640802fe316c720ed44954a506178fa8cd620683..915ad1a10ccb43fc887aceb179ac6fbc0a01c62a 100644 (file)
@@ -2246,6 +2246,7 @@ static struct nexthop netlink_nexthop_process_nh(struct rtattr **tb,
        enum nexthop_types_t type = 0;
        int if_index = 0;
        size_t sz = 0;
+       struct interface *ifp_lookup;
 
        if_index = *(int *)RTA_DATA(tb[NHA_OIF]);
 
@@ -2280,9 +2281,13 @@ static struct nexthop netlink_nexthop_process_nh(struct rtattr **tb,
        if (if_index)
                nh.ifindex = if_index;
 
-       *ifp = if_lookup_by_index_per_ns(zebra_ns_lookup(ns_id), nh.ifindex);
+       ifp_lookup =
+               if_lookup_by_index_per_ns(zebra_ns_lookup(ns_id), nh.ifindex);
+
        if (ifp)
-               nh.vrf_id = (*ifp)->vrf_id;
+               *ifp = ifp_lookup;
+       if (ifp_lookup)
+               nh.vrf_id = ifp_lookup->vrf_id;
        else {
                flog_warn(
                        EC_ZEBRA_UNKNOWN_INTERFACE,
index 2bb117b2729d886ab2740adc5f3845d226cb5bab..05da25b2b8e28f8693d73639e993095264f465d9 100644 (file)
@@ -886,8 +886,7 @@ static void nhg_ctx_process_finish(struct nhg_ctx *ctx)
        nexthop_del_labels(nh);
 
 done:
-       if (ctx)
-               nhg_ctx_free(ctx);
+       nhg_ctx_free(ctx);
 }
 
 static int queue_add(struct nhg_ctx *ctx)