]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tools: Fix CID 1364703 - resource leak
authorAmitay Isaacs <amitay@gmail.com>
Thu, 4 Aug 2016 05:50:38 +0000 (15:50 +1000)
committerMartin Schwenke <martins@samba.org>
Mon, 8 Aug 2016 06:17:33 +0000 (08:17 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12121

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/tools/ctdb.c

index c3003926a4e5055efcc3deb11cf75134d099fbe1..4e767ae0fd376f3cac26de25797205ce0b8134fb 100644 (file)
@@ -4248,18 +4248,21 @@ static int control_restoredb(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
        nodemap = get_nodemap(ctdb, false);
        if (nodemap == NULL) {
                fprintf(stderr, "Failed to get nodemap\n");
+               close(fd);
                return ENOMEM;
        }
 
        ret = get_generation(mem_ctx, ctdb, &generation);
        if (ret != 0) {
                fprintf(stderr, "Failed to get current generation\n");
+               close(fd);
                return ret;
        }
 
        count = list_of_active_nodes(nodemap, CTDB_UNKNOWN_PNN, mem_ctx,
                                     &pnn_list);
        if (count <= 0) {
+               close(fd);
                return ENOMEM;
        }
 
@@ -4390,6 +4393,7 @@ static int control_restoredb(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
 
 
 failed:
+       close(fd);
        ctdb_ctrl_set_recmode(mem_ctx, ctdb->ev, ctdb->client,
                              ctdb->pnn, TIMEOUT(), CTDB_RECOVERY_ACTIVE);
        return ret;