Browse Source

server: Fix various error paths if startup fails

Don't segfault or use heap after free if osmo-remsim-server cannot
fully initialize, e.g. due to ports already in use.

Change-Id: I558e6a0ea089a779f916aa5576341d1c55da1271
changes/28/28028/3
Harald Welte 3 months ago
parent
commit
a04ff860c1
  1. 1
      src/server/remsim_server.c
  2. 1
      src/server/rest_api.c
  3. 6
      src/server/rspro_server.c

1
src/server/remsim_server.c

@ -139,7 +139,6 @@ out_eventfd:
close(g_event_ofd.fd);
out_rps:
talloc_free(g_rps->slotmaps);
talloc_free(g_rps);
out_rspro:
rspro_server_destroy(g_rps);

1
src/server/rest_api.c

@ -512,6 +512,7 @@ int rest_api_init(void *ctx, uint16_t port)
if (ulfius_start_framework(&g_instance) != U_OK) {
LOGP(DREST, LOGL_FATAL, "Cannot start REST API on port %u\n", port);
ulfius_clean_instance(&g_instance);
return -1;
}
return 0;

6
src/server/rspro_server.c

@ -854,6 +854,11 @@ struct rspro_server *rspro_server_create(void *ctx, const char *host, uint16_t p
pthread_rwlock_unlock(&srv->rwlock);
srv->link = ipa_server_link_create(ctx, NULL, host, port, accept_cb, srv);
if (!srv->link) {
talloc_free(srv);
return NULL;
}
ipa_server_link_open(srv->link);
return srv;
@ -865,5 +870,6 @@ void rspro_server_destroy(struct rspro_server *srv)
ipa_server_link_destroy(srv->link);
srv->link = NULL;
pthread_rwlock_destroy(&srv->rwlock);
talloc_free(srv);
}

Loading…
Cancel
Save