diff options
authorPhilipp Maier <pmaier@sysmocom.de>2017-07-21 12:55:24 +0200
committerHarald Welte <laforge@gnumonks.org>2017-07-22 09:08:13 +0000
commitdcb360a9dbd418ac582b2996cf394390b154fe0a (patch)
parentdae7491c14f5e7bdfecb25fba5c2624127daadc8 (diff)
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
1 files changed, 5 insertions, 0 deletions
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 @@ int osmo_ss7_asp_use_default_lm(struct osmo_ss7_asp *asp, int log_level)
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);