From f60c3f820bf172737a2a25d041e0b8650753f2da Mon Sep 17 00:00:00 2001 From: Abhishek Saha Date: Fri, 2 Sep 2022 00:01:21 +0530 Subject: [PATCH] CORTX-33834: Fixed rpc/conn.c m0_rpc_conn_ha_timer_start() memory leak (#2113) Expanded cases covered by commit: 52cc7a5 Problem: m0_rpc_conn_ha_timer_stop() was finalizing the timer only in the case when the timer was not armed. Solution: Finalize the timer after the armed timer is stopped using m0_sm_timer_cancel() Signed-off-by: Abhishek Saha --- rpc/conn.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rpc/conn.c b/rpc/conn.c index bfc85eaeb61..6d772e63269 100644 --- a/rpc/conn.c +++ b/rpc/conn.c @@ -1454,8 +1454,9 @@ M0_INTERNAL void m0_rpc_conn_ha_timer_stop(struct m0_rpc_conn *conn) if (m0_sm_timer_is_armed(&conn->c_ha_timer)) { M0_LOG(M0_DEBUG, "Cancelling HA timer; rpc conn=%p", conn); m0_sm_timer_cancel(&conn->c_ha_timer); - } else if (M0_IN(conn->c_ha_timer.tr_timer.t_state, - (M0_TIMER_STOPPED, M0_TIMER_INITED))) + } + if (M0_IN(conn->c_ha_timer.tr_timer.t_state, + (M0_TIMER_STOPPED, M0_TIMER_INITED))) m0_sm_timer_fini(&conn->c_ha_timer); }