]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: prevent crash when nhlfe is NULL
authorDonald Sharp <sharpd@nvidia.com>
Wed, 4 Aug 2021 17:38:25 +0000 (13:38 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Wed, 4 Aug 2021 17:38:25 +0000 (13:38 -0400)
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 <sharpd@nvidia.com>
zebra/zebra_mpls.c

index f1a7c3e8c1331c70f105c5e15f24bb8473bd67de..2f83fe4e2844aafbd64f0aafd51a21c7e93ed3af 100644 (file)
@@ -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);