diff options
author | Ming Lei <ming.lei@redhat.com> | 2018-02-09 19:46:17 -0500 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-02-23 17:20:19 -0500 |
commit | 0bd1ed4860d0f5f836aa8371797689a3779d1bf5 (patch) | |
tree | 061d2a86451b27d9aff40d96cbb2effcbfb6b6c2 | |
parent | 0f9da844d87796ac31b04e81ee95e155e9043132 (diff) |
block: pass inclusive 'lend' parameter to truncate_inode_pages_range
The 'lend' parameter of truncate_inode_pages_range is required to be
inclusive, so follow the rule.
This patch fixes one memory corruption triggered by discard.
Cc: <stable@vger.kernel.org>
Cc: Dmitry Monakhov <dmonakhov@openvz.org>
Fixes: 351499a172c0 ("block: Invalidate cache on discard v2")
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | block/ioctl.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/block/ioctl.c b/block/ioctl.c index 1668506d8ed8..3884d810efd2 100644 --- a/block/ioctl.c +++ b/block/ioctl.c | |||
@@ -225,7 +225,7 @@ static int blk_ioctl_discard(struct block_device *bdev, fmode_t mode, | |||
225 | 225 | ||
226 | if (start + len > i_size_read(bdev->bd_inode)) | 226 | if (start + len > i_size_read(bdev->bd_inode)) |
227 | return -EINVAL; | 227 | return -EINVAL; |
228 | truncate_inode_pages_range(mapping, start, start + len); | 228 | truncate_inode_pages_range(mapping, start, start + len - 1); |
229 | return blkdev_issue_discard(bdev, start >> 9, len >> 9, | 229 | return blkdev_issue_discard(bdev, start >> 9, len >> 9, |
230 | GFP_KERNEL, flags); | 230 | GFP_KERNEL, flags); |
231 | } | 231 | } |