diff options
author | Daniel Willmann <daniel@totalueberwachung.de> | 2011-08-05 12:22:35 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2014-08-21 15:34:14 +0200 |
commit | 9f97316fcf99aab2420504c31884343613d6798c (patch) | |
tree | 12c9727d37653e835139e27d1b543d1843df44e1 /openbsc | |
parent | 35a1b3b493b1b11e4f6ac893b64bb43f673a371d (diff) |
ctrl: Improve error handling if controlif setup fails
Diffstat (limited to 'openbsc')
-rw-r--r-- | openbsc/src/libctrl/control_if.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/openbsc/src/libctrl/control_if.c b/openbsc/src/libctrl/control_if.c index 350e8e1c..8842d3c2 100644 --- a/openbsc/src/libctrl/control_if.c +++ b/openbsc/src/libctrl/control_if.c @@ -642,23 +642,27 @@ struct ctrl_handle *controlif_setup(struct gsm_network *gsmnet, uint16_t port) ctrl->gsmnet = gsmnet; ctrl_node_vec = vector_init(5); - if (!ctrl_node_vec) { - talloc_free(ctrl); - return NULL; - } + if (!ctrl_node_vec) + goto err; /* Listen for control connections */ ret = make_sock(&ctrl->listen_fd, IPPROTO_TCP, INADDR_LOOPBACK, port, 0, listen_fd_cb, ctrl); - if (ret < 0) { - talloc_free(ctrl); - vector_free(ctrl_node_vec); - ctrl_node_vec = NULL; - return NULL; - } + if (ret < 0) + goto err_vec; - ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_rate_ctr); - ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_counter); + ret = ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_rate_ctr); + if (ret) + goto err_vec; + ret = ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_counter); + if (ret) + goto err_vec; return ctrl; +err_vec: + vector_free(ctrl_node_vec); + ctrl_node_vec = NULL; +err: + talloc_free(ctrl); + return NULL; } |