From f6bc4c1ef8c9cb08f05548565e382d013ee38ac4 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Thu, 17 Jan 2019 10:49:21 +0700 Subject: trxcon/l1ctl_link.c: check if l1ctl_fsm allocation failed Change-Id: Ibd9404a888f02798224238a7b9ff4ebf09f03850 --- src/host/trxcon/l1ctl_link.c | 15 +++++++++++---- 1 file 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; -- cgit v1.2.3