From: Donald Sharp Date: Wed, 4 Aug 2021 17:38:25 +0000 (-0400) Subject: zebra: prevent crash when nhlfe is NULL X-Git-Tag: base_8.1~222^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=refs%2Fpull%2F9299%2Fhead;p=mirror%2Ffrr.git zebra: prevent crash when nhlfe is NULL There exists a call path where the nhlfe_alloc can return NULL for blackhole nexthops. In this case we were still trying to save the nhlfe pointer causing a crash when we attempted to add it to a self-contained list. Signed-off-by: Donald Sharp --- diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index f1a7c3e8c1..2f83fe4e28 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -1323,6 +1323,9 @@ static zebra_nhlfe_t *nhlfe_add(zebra_lsp_t *lsp, enum lsp_types_t lsp_type, nhlfe = nhlfe_alloc(lsp, lsp_type, gtype, gate, ifindex, num_labels, labels); + if (!nhlfe) + return NULL; + /* Enqueue to LSP: primaries at head of list, backups at tail */ if (is_backup) { SET_FLAG(nhlfe->flags, NHLFE_FLAG_IS_BACKUP);