btrfs: return error value if create_io_em failed in cow_file_range
authorSu Yue <suy.fnst@cn.fujitsu.com>
Wed, 30 May 2018 08:48:56 +0000 (16:48 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 26 Jun 2018 00:06:30 +0000 (08:06 +0800)
commit4cb8942042bde6b58cac0c76d12a24b62ab0c76c
tree480a5558e66c8e14b3526b6a0d2a5d1e938f41db
parent5f7e3b5b96f8b787e95bfd91636261fd32d80dc2
btrfs: return error value if create_io_em failed in cow_file_range

commit 090a127afa8f73e9618d4058d6755f7ec7453dd6 upstream.

In cow_file_range(), create_io_em() may fail, but its return value is
not recorded.  Then return value may be 0 even it failed which is a
wrong behavior.

Let cow_file_range() return PTR_ERR(em) if create_io_em() failed.

Fixes: 6f9994dbabe5 ("Btrfs: create a helper to create em for IO")
CC: stable@vger.kernel.org # 4.11+
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.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/inode.c