Skip to content

Commit 0bd1ed4

Browse files
Ming Leiaxboe
authored andcommitted
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: <[email protected]> Cc: Dmitry Monakhov <[email protected]> Fixes: 351499a ("block: Invalidate cache on discard v2") Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 0f9da84 commit 0bd1ed4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

block/ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ static int blk_ioctl_discard(struct block_device *bdev, fmode_t mode,
225225

226226
if (start + len > i_size_read(bdev->bd_inode))
227227
return -EINVAL;
228-
truncate_inode_pages_range(mapping, start, start + len);
228+
truncate_inode_pages_range(mapping, start, start + len - 1);
229229
return blkdev_issue_discard(bdev, start >> 9, len >> 9,
230230
GFP_KERNEL, flags);
231231
}

0 commit comments

Comments
 (0)