]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
btrfs: don't double unlock on error in btrfs_punch_hole
authorJosef Bacik <josef@toxicpanda.com>
Fri, 3 May 2019 15:10:06 +0000 (11:10 -0400)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 12 Aug 2019 09:59:42 +0000 (11:59 +0200)
BugLink: https://bugs.launchpad.net/bugs/1837517
commit 8fca955057b9c58467d1b231e43f19c4cf26ae8c upstream.

If we have an error writing out a delalloc range in
btrfs_punch_hole_lock_range we'll unlock the inode and then goto
out_only_mutex, where we will again unlock the inode.  This is bad,
don't do this.

Fixes: f27451f22996 ("Btrfs: add support for fallocate's zero range operation")
CC: stable@vger.kernel.org # 4.19+
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/btrfs/file.c

index d38dc8c31533773df9ac8cef15254319df824cba..d391e07200f6aee96f6092f4ae455ce9aa0767f5 100644 (file)
@@ -2546,10 +2546,8 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
 
        ret = btrfs_punch_hole_lock_range(inode, lockstart, lockend,
                                          &cached_state);
-       if (ret) {
-               inode_unlock(inode);
+       if (ret)
                goto out_only_mutex;
-       }
 
        path = btrfs_alloc_path();
        if (!path) {