summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2019-01-17 10:53:10 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2019-01-17 10:53:10 +0700
commit192a8595d0161cf1a095c7386c153c99ed2c1bc3 (patch)
tree857deb1807bb75e73211df7ae33fa034384df026
parentf6bc4c1ef8c9cb08f05548565e382d013ee38ac4 (diff)
trxcon/trx_if.c: check if trx_fsm allocation failed
-rw-r--r--src/host/trxcon/trx_if.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/host/trxcon/trx_if.c b/src/host/trxcon/trx_if.c
index 91b87a2..bff73cc 100644
--- a/src/host/trxcon/trx_if.c
+++ b/src/host/trxcon/trx_if.c
@@ -645,6 +645,16 @@ int trx_if_open(struct trx_instance **trx, const char *local_host,
return -ENOMEM;
}
+ /* Allocate a new dedicated state machine */
+ trx_new->fsm = osmo_fsm_inst_alloc(&trx_fsm, trx_new,
+ NULL, LOGL_DEBUG, "trx_interface");
+ if (trx_new->fsm == NULL) {
+ LOGP(DTRX, LOGL_ERROR, "Failed to allocate an instance "
+ "of FSM '%s'\n", trx_fsm.name);
+ talloc_free(trx_new);
+ return -ENOMEM;
+ }
+
/* Initialize CTRL queue */
INIT_LLIST_HEAD(&trx_new->trx_ctrl_list);
@@ -659,16 +669,13 @@ int trx_if_open(struct trx_instance **trx, const char *local_host,
if (rc < 0)
goto error;
- /* Allocate a new dedicated state machine */
- trx_new->fsm = osmo_fsm_inst_alloc(&trx_fsm, trx_new,
- NULL, LOGL_DEBUG, "trx_interface");
-
*trx = trx_new;
return 0;
error:
LOGP(DTRX, LOGL_ERROR, "Couldn't establish UDP connection\n");
+ osmo_fsm_inst_free(trx_new->fsm);
talloc_free(trx_new);
return rc;
}