laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-remsim/+/31181 )
Change subject: rspro_server: Handle ipa_server_link_open() error case ......................................................................
rspro_server: Handle ipa_server_link_open() error case
CID 307530: Error handling issues (CHECKED_RETURN) Calling "ipa_server_link_open" without checking return value (as is done elsewhere 4 out of 5
times).
while at it, also add a missing pthread_rwlock_destroy() call which was missing in the existing ipa_server_link_create() error path.
Closes: CID#307530 Change-Id: Ic32d53a236b80711651fb4ee196ac3b95148e61f --- M src/server/rspro_server.c 1 file changed, 14 insertions(+), 5 deletions(-)
Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified
diff --git a/src/server/rspro_server.c b/src/server/rspro_server.c index 550179d..da27a2d 100644 --- a/src/server/rspro_server.c +++ b/src/server/rspro_server.c @@ -844,6 +844,7 @@
{ struct rspro_server *srv = talloc_zero(ctx, struct rspro_server); + int rc; OSMO_ASSERT(srv);
pthread_rwlock_init(&srv->rwlock, NULL); @@ -854,14 +855,22 @@ 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; - } + if (!srv->link) + goto out_free;
- ipa_server_link_open(srv->link); + rc = ipa_server_link_open(srv->link); + if (rc < 0) + goto out_destroy;
return srv; + +out_destroy: + ipa_server_link_destroy(srv->link); +out_free: + pthread_rwlock_destroy(&srv->rwlock); + talloc_free(srv); + + return NULL; }
void rspro_server_destroy(struct rspro_server *srv)