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 <[email protected]>
Gerrit-Reviewer: Harald Welte <[email protected]>
Gerrit-Reviewer: Jenkins Builder

Reply via email to