From 56c226e77322e77e1d09fa9d39b16864431a6126 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 4 Nov 2020 21:02:57 -0500 Subject: [PATCH] bgpd: Cleanup memory leaks associated with t_router_timer We are allocating temporary memory for information about what to process in this thread, which is not being cleaned up on thread cancelling. Signed-off-by: Donald Sharp --- bgpd/bgp_route.c | 7 ++++++- bgpd/bgpd.c | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 0a741d1c4a..8a237e329e 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -2919,8 +2919,13 @@ int bgp_best_path_select_defer(struct bgp *bgp, afi_t afi, safi_t safi) int cnt = 0; struct afi_safi_info *thread_info; - if (bgp->gr_info[afi][safi].t_route_select) + if (bgp->gr_info[afi][safi].t_route_select) { + struct thread *t = bgp->gr_info[afi][safi].t_route_select; + + thread_info = THREAD_ARG(t); + XFREE(MTYPE_TMP, thread_info); BGP_TIMER_OFF(bgp->gr_info[afi][safi].t_route_select); + } if (BGP_DEBUG(update, UPDATE_OUT)) { zlog_debug("%s: processing route for %s : cnt %d", __func__, diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index f868128e60..0095a1cab0 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -3394,11 +3394,20 @@ int bgp_delete(struct bgp *bgp) /* Delete the graceful restart info */ FOREACH_AFI_SAFI (afi, safi) { + struct thread *t; + gr_info = &bgp->gr_info[afi][safi]; if (!gr_info) continue; BGP_TIMER_OFF(gr_info->t_select_deferral); + + t = gr_info->t_route_select; + if (t) { + void *info = THREAD_ARG(t); + + XFREE(MTYPE_TMP, info); + } BGP_TIMER_OFF(gr_info->t_route_select); } -- 2.39.5