From: Stephen Worley Date: Tue, 29 Oct 2019 01:37:05 +0000 (-0400) Subject: zebra: handle depends_find() NULL nexthop X-Git-Tag: base_7.3~154^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=606fa9e58dd5b5b2e6eceb23f80d30a0376eba6a;p=matthieu%2Ffrr.git 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 --- 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; }