[PATCH] openbsc[master]: abis_om2k: protect MO FSMs by NULL check

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/.

lynxis lazus gerrit-no-reply at lists.osmocom.org
Mon Mar 13 09:04:54 UTC 2017


Review at  https://gerrit.osmocom.org/2037

abis_om2k: protect MO FSMs by NULL check

Also set MO FSMs to NULL after freeing them.

Change-Id: I30df0b9ab8bc47ba9756c8388e977deed0e40200
---
M openbsc/src/libbsc/abis_om2000.c
1 file changed, 17 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/37/2037/1

diff --git a/openbsc/src/libbsc/abis_om2000.c b/openbsc/src/libbsc/abis_om2000.c
index 54e9b7c..b01aacf 100644
--- a/openbsc/src/libbsc/abis_om2000.c
+++ b/openbsc/src/libbsc/abis_om2000.c
@@ -1695,7 +1695,17 @@
 
 static void om2k_mo_s_done_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
 {
+	struct om2k_mo_fsm_priv *omfp = fi->priv;
+	omfp->mo->fsm = NULL;
 	osmo_fsm_inst_term(fi, OSMO_FSM_TERM_REGULAR, NULL);
+}
+
+static void om2k_mo_s_error_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
+{
+	struct om2k_mo_fsm_priv *omfp = fi->priv;
+
+	omfp->mo->fsm = NULL;
+	osmo_fsm_inst_term(fi, OSMO_FSM_TERM_ERROR, NULL);
 }
 
 static const struct osmo_fsm_state om2k_is_states[] = {
@@ -1792,7 +1802,7 @@
 		.name = "ERROR",
 		.in_event_mask = 0,
 		.out_state_mask = 0,
-		.onenter = om2k_mo_s_done_onenter,
+		.onenter = om2k_mo_s_error_onenter,
 	},
 
 };
@@ -2695,6 +2705,12 @@
 		     msgb_hexdump(msg));
 		return 0;
 	}
+	if (!mo->fsm) {
+		LOGP(DNM, LOGL_ERROR, "MO object should not generate any message. fsm == NULL "
+		     "%s: %s\n", get_value_string(om2k_msgcode_vals, msg_type),
+		     msgb_hexdump(msg));
+		return 0;
+	}
 
 	/* Dispatch message to that MO */
 	om2k_mo_fsm_recvmsg(bts, mo, &odm);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I30df0b9ab8bc47ba9756c8388e977deed0e40200
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>



More information about the gerrit-log mailing list