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
This commit is contained in:
Harald Welte 2023-02-03 20:28:29 +01:00
parent ae0d9d2e60
commit 5426124dc7
1 changed files with 14 additions and 5 deletions

View File

@ -844,6 +844,7 @@ struct rspro_server *rspro_server_create(void *ctx, const char *host, uint16_t p
{
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 @@ 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;
}
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)