From 4f80a6bc6831132a148769d24efe13be88d6fe7d Mon Sep 17 00:00:00 2001 From: Enke Chen Date: Wed, 8 Jan 2025 11:59:39 -0800 Subject: [PATCH] bgpd: fix memory leak in bgp_aggregate_install() Potential memory leak with as-set and matching-MED-only config. Signed-off-by: Enke Chen --- bgpd/bgp_route.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 88d7704ac95c..447c83017c58 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -8000,8 +8000,13 @@ static void bgp_aggregate_install( * If we have paths with different MEDs, then don't install * (or uninstall) the aggregate route. */ - if (aggregate->match_med && aggregate->med_mismatched) + if (aggregate->match_med && aggregate->med_mismatched) { + aspath_free(aspath); + community_free(&community); + ecommunity_free(&ecommunity); + lcommunity_free(&lcommunity); goto uninstall_aggregate_route; + } if (aggregate->count > 0) { /*