From e9f6516243f58a856bc467a2ca95730cb7cabfc7 Mon Sep 17 00:00:00 2001 From: Stephen Worley Date: Tue, 3 Sep 2019 15:10:21 -0400 Subject: [PATCH] zebra: Fix NULL check in zebra_nhg_rib_find() Check both the nhg and nexthop are not NULL before passing them to be hashed. Clang SA caught this. Signed-off-by: Stephen Worley --- zebra/zebra_nhg.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 8cc187710..8fb4f3357 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -1033,15 +1033,13 @@ zebra_nhg_rib_find(uint32_t id, struct nexthop_group *nhg, afi_t rt_afi) { struct nhg_hash_entry *nhe = NULL; - vrf_id_t nhg_vrf_id = nhg->nexthop->vrf_id; - - if (!nhg) { + if (!(nhg && nhg->nexthop)) { flog_err(EC_ZEBRA_TABLE_LOOKUP_FAILED, "No nexthop passed to %s", __func__); return NULL; } - zebra_nhg_find(&nhe, id, nhg, NULL, nhg_vrf_id, rt_afi, 0); + zebra_nhg_find(&nhe, id, nhg, NULL, nhg->nexthop->vrf_id, rt_afi, 0); return nhe; } -- 2.39.5