]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
btrfs: propagate error to btrfs_cmp_data_prepare caller
authorNaohiro Aota <naohiro.aota@wdc.com>
Fri, 8 Sep 2017 08:48:55 +0000 (17:48 +0900)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 12 Oct 2017 21:20:52 +0000 (16:20 -0500)
BugLink: http://bugs.launchpad.net/bugs/1721777
commit 78ad4ce014d025f41b8dde3a81876832ead643cf upstream.

btrfs_cmp_data_prepare() (almost) always returns 0 i.e. ignoring errors
from gather_extent_pages(). While the pages are freed by
btrfs_cmp_data_free(), cmp->num_pages still has > 0. Then,
btrfs_extent_same() try to access the already freed pages causing faults
(or violates PageLocked assertion).

This patch just return the error as is so that the caller stop the process.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Fixes: f441460202cb ("btrfs: fix deadlock with extent-same and readpage")
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: Seth Forshee <seth.forshee@canonical.com>
fs/btrfs/ioctl.c

index fa1b78cf25f68083de3db86ead690a41563316ce..8f1bfd512afced562c07099e69f6243564262b2b 100644 (file)
@@ -3063,7 +3063,7 @@ static int btrfs_cmp_data_prepare(struct inode *src, u64 loff,
 out:
        if (ret)
                btrfs_cmp_data_free(cmp);
-       return 0;
+       return ret;
 }
 
 static int btrfs_cmp_data(u64 len, struct cmp_pages *cmp)