pespin has submitted this change. (
https://gerrit.osmocom.org/c/osmo-hnbgw/+/28283 )
Change subject: mgw_fsm: Fix error path accessing uninitialized fsm ptr
......................................................................
mgw_fsm: Fix error path accessing uninitialized fsm ptr
The error handling of the error path was wrong. Let's remove the "fi"
variable to avoid more of such errors. Furthermore, add an assert to
clarify for the reader that the map->mgw_fi will be freed before
allocating a new FSM instance below.
Change-Id: I9d3bca552bfa77f5e18f75bedad8d422f74df1f8
---
M src/osmo-hnbgw/mgw_fsm.c
1 file changed, 4 insertions(+), 5 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
fixeria: Looks good to me, but someone else must approve
diff --git a/src/osmo-hnbgw/mgw_fsm.c b/src/osmo-hnbgw/mgw_fsm.c
index 2b7484f..1360849 100644
--- a/src/osmo-hnbgw/mgw_fsm.c
+++ b/src/osmo-hnbgw/mgw_fsm.c
@@ -658,7 +658,6 @@
int handle_rab_ass_req(struct hnbgw_context_map *map, struct osmo_prim_hdr *oph,
ranap_message *message)
{
static bool initialized = false;
- struct osmo_fsm_inst *fi;
struct mgw_fsm_priv *mgw_fsm_priv;
struct osmo_sockaddr addr;
struct osmo_sockaddr_str addr_str;
@@ -683,7 +682,8 @@
LOGPFSML(map->mgw_fi, LOGL_ERROR,
"mgw_fsm_alloc_and_handle_rab_ass_req() unable to handle
RAB-AssignmentRequest!\n");
- osmo_fsm_inst_state_chg(fi, MGW_ST_FAILURE, 0, 0);
+ osmo_fsm_inst_state_chg(map->mgw_fi, MGW_ST_FAILURE, 0, 0);
+ OSMO_ASSERT(map->mgw_fi == NULL);
}
mgw_fsm_priv = talloc_zero(map, struct mgw_fsm_priv);
@@ -723,9 +723,8 @@
/* Allocate the FSM and start it. */
mgw_fsm_priv->map = map;
snprintf(fsm_name, sizeof(fsm_name), "mgw-fsm-%u-%u", map->rua_ctx_id,
mgw_fsm_priv->rab_id);
- fi = osmo_fsm_inst_alloc(&mgw_fsm, map, mgw_fsm_priv, LOGL_DEBUG, fsm_name);
- map->mgw_fi = fi;
- mgw_fsm_state_chg(fi, MGW_ST_CRCX_HNB);
+ map->mgw_fi = osmo_fsm_inst_alloc(&mgw_fsm, map, mgw_fsm_priv, LOGL_DEBUG,
fsm_name);
+ mgw_fsm_state_chg(map->mgw_fi, MGW_ST_CRCX_HNB);
return 0;
error:
--
To view, visit
https://gerrit.osmocom.org/c/osmo-hnbgw/+/28283
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: I9d3bca552bfa77f5e18f75bedad8d422f74df1f8
Gerrit-Change-Number: 28283
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged