From f5158712078be06211ad26b1e887209c6b15cab1 Mon Sep 17 00:00:00 2001 From: Mark Stapp Date: Fri, 21 Aug 2020 09:34:19 -0400 Subject: [PATCH] zebra: fix SA warning in rib_process() Fix an SA warning about a possible NULL pointer deref in rib_process(). Signed-off-by: Mark Stapp --- zebra/zebra_rib.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index abc3ba5f33..8852ee9467 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -1028,21 +1028,23 @@ static void rib_process(struct route_node *rn) if (IS_ZEBRA_DEBUG_RIB) srcdest_rnode2str(rn, buf, sizeof(buf)); - if (IS_ZEBRA_DEBUG_RIB_DETAILED) { - struct route_entry *re = re_list_first(&dest->routes); - - zlog_debug("%s(%u:%u):%s: Processing rn %p", VRF_LOGNAME(vrf), - vrf_id, re->table, buf, rn); - } - /* * we can have rn's that have a NULL info pointer * (dest). As such let's not let the deref happen * additionally we know RNODE_FOREACH_RE_SAFE * will not iterate so we are ok. */ - if (dest) + if (dest) { + if (IS_ZEBRA_DEBUG_RIB_DETAILED) { + struct route_entry *re = re_list_first(&dest->routes); + + zlog_debug("%s(%u:%u):%s: Processing rn %p", + VRF_LOGNAME(vrf), vrf_id, re->table, buf, + rn); + } + old_fib = dest->selected_fib; + } RNODE_FOREACH_RE_SAFE (rn, re, next) { if (IS_ZEBRA_DEBUG_RIB_DETAILED) -- 2.39.5