summaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorFilipe Manana2019-01-08 12:42:01 +0100
committerDavid Sterba2019-02-25 14:13:21 +0100
commitd00c2d9c76975d70089418dc1447b51da3a6a118 (patch)
tree4ab81a974750e3ae29b14866a0e936edf3afd278 /fs/btrfs
parentBtrfs: do not overwrite error return value in the device replace ioctl (diff)
downloadkernel-qcow2-linux-d00c2d9c76975d70089418dc1447b51da3a6a118.tar.gz
kernel-qcow2-linux-d00c2d9c76975d70089418dc1447b51da3a6a118.tar.xz
kernel-qcow2-linux-d00c2d9c76975d70089418dc1447b51da3a6a118.zip
Btrfs: do not overwrite error return value in the balance ioctl
If the call to btrfs_balance() failed we would overwrite the error returned to user space with -EFAULT if the call to copy_to_user() failed as well. Fix that by calling copy_to_user() only if btrfs_balance() returned success or was canceled. Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/ioctl.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index b07b19acdbb1..c21cc408556d 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -4781,7 +4781,7 @@ do_balance:
ret = btrfs_balance(fs_info, bctl, bargs);
bctl = NULL;
- if (arg) {
+ if ((ret == 0 || ret == -ECANCELED) && arg) {
if (copy_to_user(arg, bargs, sizeof(*bargs)))
ret = -EFAULT;
}