From: James Jones Date: Mon, 20 Nov 2023 21:24:08 +0000 (-0600) Subject: Hoist mutex lock above check of client->ht (CID #1551708) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2e4cd4c2c67e04e4abf6f255d505f48dcb43c50;p=thirdparty%2Ffreeradius-server.git Hoist mutex lock above check of client->ht (CID #1551708) Other checks of client->ht are so guarded. --- diff --git a/src/lib/io/master.c b/src/lib/io/master.c index caaef884fa3..bff1ef11b5e 100644 --- a/src/lib/io/master.c +++ b/src/lib/io/master.c @@ -785,20 +785,21 @@ static fr_io_connection_t *fr_io_connection_alloc(fr_io_instance_t const *inst, * Add the connection to the set of connections for this * client. */ + pthread_mutex_lock(&client->mutex); if (client->ht) { - pthread_mutex_lock(&client->mutex); if (nak) (void) fr_hash_table_delete(client->ht, nak); ret = fr_hash_table_insert(client->ht, connection); client->ready_to_delete = false; - pthread_mutex_unlock(&client->mutex); if (!ret) { + pthread_mutex_unlock(&client->mutex); ERROR("proto_%s - Failed inserting connection into tracking table. " "Closing it, and discarding all packets for connection %s.", inst->app_io->common.name, connection->name); goto cleanup; } } + pthread_mutex_unlock(&client->mutex); /* * It's a NAK client. Set the state to NAK, and don't