btrfs-progs: check, fix path leak in error branch
authorDavid Sterba <dsterba@suse.cz>
Tue, 30 Dec 2014 13:52:55 +0000 (14:52 +0100)
committerDavid Sterba <dsterba@suse.cz>
Tue, 30 Dec 2014 14:48:54 +0000 (15:48 +0100)
Resolves-coverity-id: 1260250
Signed-off-by: David Sterba <dsterba@suse.cz>
cmds-check.c

index e74b116..71e4f4f 100644 (file)
@@ -2839,7 +2839,7 @@ static int repair_btree(struct btrfs_root *root,
                ret = PTR_ERR(trans);
                fprintf(stderr, "Error starting transaction: %s\n",
                        strerror(-ret));
-               return ret;
+               goto out_free_path;
        }
        cache = first_cache_extent(corrupt_blocks);
        while (cache) {
@@ -2894,8 +2894,9 @@ static int repair_btree(struct btrfs_root *root,
                cache = next_cache_extent(cache);
        }
 out:
-       btrfs_free_path(path);
        btrfs_commit_transaction(trans, root);
+out_free_path:
+       btrfs_free_path(path);
        return ret;
 }