[MERGED] libosmo-sccp[master]: xua: fix possible memory leak in seems osmo_ss7_asp_use_defa...

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sat Jul 22 09:08:14 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: xua: fix possible memory leak in seems osmo_ss7_asp_use_default_lm()
......................................................................


xua: fix possible memory leak in seems osmo_ss7_asp_use_default_lm()

The function seems osmo_ss7_asp_use_default_lm() does not guard
against an asp->lm_priv FSM instance already existing. If this
function is called a second time, it will overwrite asp->lm_priv,
causing the original fsm instance to leaked.

Check if asp->lm_priv already exists and terminate (free) the
FSM if present.

Change-Id: I4ad435c042a435c4e641c6e5c53b91265dd23d40
---
M src/xua_default_lm_fsm.c
1 file changed, 5 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/xua_default_lm_fsm.c b/src/xua_default_lm_fsm.c
index 9308de4..2a03cbc 100644
--- a/src/xua_default_lm_fsm.c
+++ b/src/xua_default_lm_fsm.c
@@ -366,6 +366,11 @@
 	struct lm_fsm_priv *lmp;
 	struct osmo_fsm_inst *fi;
 
+	if (asp->lm_priv) {
+		osmo_fsm_inst_term(asp->lm_priv, OSMO_FSM_TERM_ERROR, NULL);
+		asp->lm_priv = NULL;
+	}
+
 	fi = osmo_fsm_inst_alloc(&xua_default_lm_fsm, asp, NULL, log_level, asp->cfg.name);
 
 	lmp = talloc_zero(fi, struct lm_fsm_priv);

-- 
To view, visit https://gerrit.osmocom.org/3325
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4ad435c042a435c4e641c6e5c53b91265dd23d40
Gerrit-PatchSet: 3
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list