ctdb: Coverity fix for CID 1291643
authorRajesh Joseph <rjoseph@redhat.com>
Tue, 31 Mar 2015 13:13:36 +0000 (18:43 +0530)
committerMichael Adam <obnox@samba.org>
Wed, 1 Apr 2015 10:54:11 +0000 (12:54 +0200)
CID 1291643: Resource leak: leaked_handle: Handle
variable lock_fd going out of scope leaks the handle.

Fix: on failure case release handle variable lock_fd

Signed-off-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
ctdb/tcp/tcp_connect.c

index 6950ac85522b29d1ce6c3e439423c59f3a1d84ae..22131f789b189d6279ca6db27ab2da9b8b1b053e 100644 (file)
@@ -347,7 +347,12 @@ static int ctdb_tcp_listen_automatic(struct ctdb_context *ctdb)
        ctdb->address = talloc_memdup(ctdb,
                                      &ctdb->nodes[i]->address,
                                      sizeof(ctdb_sock_addr));
-       CTDB_NO_MEMORY(ctdb, ctdb->address);
+       if (ctdb->address == NULL) {
+               ctdb_set_error(ctdb, "Out of memory at %s:%d",
+                              __FILE__, __LINE__);
+               goto failed;
+       }
+
        ctdb->name = talloc_asprintf(ctdb, "%s:%u",
                                     ctdb_addr_to_str(ctdb->address),
                                     ctdb_addr_to_port(ctdb->address));