From 36ce18d278456ec0084b92ece0100fb5effb23e3 Mon Sep 17 00:00:00 2001 From: Enke Chen Date: Thu, 9 Jan 2025 14:48:35 -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 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 88d7704ac95c..88e426fdb74c 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -8000,8 +8000,15 @@ 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); + if (debug) + zlog_debug(" aggregate %pFX: med mismatch", p); goto uninstall_aggregate_route; + } if (aggregate->count > 0) { /*