]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Prevent accidental re memory leak in odd case
authorDonald Sharp <sharpd@nvidia.com>
Wed, 26 Jun 2024 17:21:38 +0000 (13:21 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Tue, 27 Aug 2024 10:25:34 +0000 (06:25 -0400)
There exists a path in rib_add_multipath where if a decision
is made to not use the passed in re, we just drop the memory
instead of freeing it.  Let's free it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
zebra/zebra_rib.c

index 2d6c5148833afab15d2d80b3d1f4cb817e02fe5c..b4baee148aef6b11787808c8f307fac41f1de315 100644 (file)
@@ -4375,8 +4375,10 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
                return -1;
 
        /* We either need nexthop(s) or an existing nexthop id */
-       if (ng == NULL && re->nhe_id == 0)
+       if (ng == NULL && re->nhe_id == 0) {
+               zebra_rib_route_entry_free(re);
                return -1;
+       }
 
        /*
         * Use a temporary nhe to convey info to the common/main api.