trxcon/trx_if.c: check if trx_fsm allocation failed

Change-Id: I31c9f2a651182b258d0a4d4504365b778529715a
This commit is contained in:
Vadim Yanitskiy 2019-01-17 10:53:10 +07:00
parent f6bc4c1ef8
commit 192a8595d0
1 changed files with 11 additions and 4 deletions

View File

@ -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;
}