From 606fa9e58dd5b5b2e6eceb23f80d30a0376eba6a Mon Sep 17 00:00:00 2001 From: Stephen Worley Date: Mon, 28 Oct 2019 21:37:05 -0400 Subject: [PATCH] zebra: handle depends_find() NULL nexthop SA warned us lookup could be NULL dereferenced in some paths. Handle the case where we are passed a NULL nexthop before we try to copy it. Signed-off-by: Stephen Worley --- zebra/zebra_nhg.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 05da25b2b8..7fe66ff77f 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -1000,6 +1000,9 @@ static struct nhg_hash_entry *depends_find(struct nexthop *nh, afi_t afi) struct nexthop *lookup = NULL; struct nhg_hash_entry *nhe = NULL; + if (!nh) + goto done; + copy_nexthops(&lookup, nh, NULL); /* Clear it, in case its a group */ @@ -1012,6 +1015,7 @@ static struct nhg_hash_entry *depends_find(struct nexthop *nh, afi_t afi) nexthops_free(lookup); +done: return nhe; } -- 2.39.5