From f6f34f85f7b7720fb07e09532fe9c25369f0a945 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 26 Jun 2024 13:21:38 -0400 Subject: [PATCH] zebra: Prevent accidental re memory leak in odd case 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 --- zebra/zebra_rib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 2d6c5148833a..b4baee148aef 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -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.