summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/host/trxcon/l1ctl_link.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/host/trxcon/l1ctl_link.c b/src/host/trxcon/l1ctl_link.c
index 23019fda..1350c3c1 100644
--- a/src/host/trxcon/l1ctl_link.c
+++ b/src/host/trxcon/l1ctl_link.c
@@ -243,6 +243,16 @@ int l1ctl_link_init(struct l1ctl_link **l1l, const char *sock_path)
return -ENOMEM;
}
+ /* Allocate a new dedicated state machine */
+ l1l_new->fsm = osmo_fsm_inst_alloc(&l1ctl_fsm, l1l_new,
+ NULL, LOGL_DEBUG, "l1ctl_link");
+ if (l1l_new->fsm == NULL) {
+ LOGP(DTRX, LOGL_ERROR, "Failed to allocate an instance "
+ "of FSM '%s'\n", l1ctl_fsm.name);
+ talloc_free(l1l_new);
+ return -ENOMEM;
+ }
+
/* Create a socket and bind handlers */
bfd = &l1l_new->listen_bfd;
rc = osmo_sock_unix_init_ofd(bfd, SOCK_STREAM, 0, sock_path,
@@ -250,6 +260,7 @@ int l1ctl_link_init(struct l1ctl_link **l1l, const char *sock_path)
if (rc < 0) {
LOGP(DL1C, LOGL_ERROR, "Could not create UNIX socket: %s\n",
strerror(errno));
+ osmo_fsm_inst_free(l1l_new->fsm);
talloc_free(l1l_new);
return rc;
}
@@ -268,10 +279,6 @@ int l1ctl_link_init(struct l1ctl_link **l1l, const char *sock_path)
*/
l1l_new->wq.bfd.fd = -1;
- /* Allocate a new dedicated state machine */
- l1l_new->fsm = osmo_fsm_inst_alloc(&l1ctl_fsm, l1l_new,
- NULL, LOGL_DEBUG, "l1ctl_link");
-
*l1l = l1l_new;
return 0;