client: Fix a memory leak in an error path
authorBart Van Assche <bvanassche@acm.org>
Sat, 30 May 2020 21:58:34 +0000 (14:58 -0700)
committerBart Van Assche <bvanassche@acm.org>
Tue, 9 Jun 2020 14:11:54 +0000 (07:11 -0700)
This patch fixes the following Coverity complaint:

CID 300985 (#1 of 1): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable client going out of scope leaks the storage it points to.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
client.c

index b75755963dcb406146376f3cc1e0121adddab94e..7e5ac17de8f380e411eb2590610d2e01c0e5f34d 100644 (file)
--- a/client.c
+++ b/client.c
@@ -471,8 +471,10 @@ int fio_client_add(struct client_ops *ops, const char *hostname, void **cookie)
                                        &client->is_sock, &client->port,
                                        &client->addr.sin_addr,
                                        &client->addr6.sin6_addr,
-                                       &client->ipv6))
+                                       &client->ipv6)) {
+               fio_put_client(client);
                return -1;
+       }
 
        client->fd = -1;
        client->ops = ops;