diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2019-01-17 10:53:10 +0700 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2019-01-17 10:53:10 +0700 |
commit | 192a8595d0161cf1a095c7386c153c99ed2c1bc3 (patch) | |
tree | 857deb1807bb75e73211df7ae33fa034384df026 /src/host/trxcon/trx_if.c | |
parent | f6bc4c1ef8c9cb08f05548565e382d013ee38ac4 (diff) |
trxcon/trx_if.c: check if trx_fsm allocation failed
Change-Id: I31c9f2a651182b258d0a4d4504365b778529715a
Diffstat (limited to 'src/host/trxcon/trx_if.c')
-rw-r--r-- | src/host/trxcon/trx_if.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/host/trxcon/trx_if.c b/src/host/trxcon/trx_if.c index 91b87a2a..bff73ccf 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; } |