summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLukas Czerner <lczerner@redhat.com>2012-10-16 11:34:36 +0200
committerChris Mason <chris.mason@fusionio.com>2012-10-25 21:46:22 +0200
commite515c18bfef718a7900924d50198d968565dd60e (patch)
tree0ea52f8adab494952efc725384394b212142461f /fs
parentBtrfs: fix memory leak in btrfs_quota_enable() (diff)
downloadlinux-e515c18bfef718a7900924d50198d968565dd60e.tar.xz
linux-e515c18bfef718a7900924d50198d968565dd60e.zip
btrfs: Return EINVAL when length to trim is less than FSB
Currently if len argument in btrfs_ioctl_fitrim() is smaller than one FSB we will continue and finally return 0 bytes discarded. However if the length to discard is smaller then file system block we should really return EINVAL. Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/ioctl.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index f5a2e6c4320a..da518ded34bd 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -343,7 +343,8 @@ static noinline int btrfs_ioctl_fitrim(struct file *file, void __user *arg)
return -EOPNOTSUPP;
if (copy_from_user(&range, arg, sizeof(range)))
return -EFAULT;
- if (range.start > total_bytes)
+ if (range.start > total_bytes ||
+ range.len < fs_info->sb->s_blocksize)
return -EINVAL;
range.len = min(range.len, total_bytes - range.start);