Btrfs: do not overwrite error return value in the get device stats ioctl
PATCH 1/1 Btrfs: do not overwrite error return value in the get device stats ioctl
From: Filipe Manana <[email protected]>
If the call to btrfs_get_dev_stats() 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_get_dev_stats() returned success.
Signed-off-by Filipe Manana <[email protected]>
--- fs/btrfs/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/ioctl.c +1 -1
@@ -4355,7 +4355,7 @@ static long btrfs_ioctl_get_dev_stats(struct btrfs_fs_info *fs_info, ret =btrfs_get_dev_stats (fs_info, sa); -if (copy_to_user (arg, sa,sizeof (*sa))) +if (ret ==0 &©_to_user (arg, sa,sizeof (*sa))) ret = -EFAULT ;kfree (sa);
Signature · 1 line
2.11.0
Looks good,
Reviewed-by Johannes Thumshirn <[email protected]>
But I agree with Nick's review on the scrub progress ioctl patch, splitting the error handling into two parts is easier to read.
Signature · 6 lines
Johannes Thumshirn SUSE Labs Filesystems [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850