btrfs: don't leak ret from do_chunk_alloc
authorJosef Bacik <josef@toxicpanda.com>
Thu, 19 Jul 2018 14:49:51 +0000 (10:49 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Sep 2018 07:16:22 +0000 (09:16 +0200)
commit 4559b0a71749c442d34f7cfb9e72c9e58db83948 upstream.

If we're trying to make a data reservation and we have to allocate a
data chunk we could leak ret == 1, as do_chunk_alloc() will return 1 if
it allocated a chunk.  Since the end of the function is the success path
just return 0.

CC: stable@vger.kernel.org # 4.4+
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/extent-tree.c

index 3f5fc150c2b7c55126734e34e0784a80a0b4eb08..b2937b645b62a16674353b7bece1366dd12b5b40 100644 (file)
@@ -4281,7 +4281,7 @@ static int flush_space(struct btrfs_root *root,
                break;
        }
 
-       return ret;
+       return 0;
 }
 
 static inline u64