summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2019-01-17 10:49:21 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2019-01-17 10:50:17 +0700
commitf6bc4c1ef8c9cb08f05548565e382d013ee38ac4 (patch)
treec8bd919c19304e0c62bfbb5fc6c5a21b9497e8e6
parentebbd601324773542f308e7e4fd6d4762bf869fd4 (diff)
trxcon/l1ctl_link.c: check if l1ctl_fsm allocation failed
-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 23019fd..1350c3c 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;