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>
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]);
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,
nexthop_del_labels(nh);
done:
- if (ctx)
- nhg_ctx_free(ctx);
+ nhg_ctx_free(ctx);
}
static int queue_add(struct nhg_ctx *ctx)