From c76c4aa1684e5cc1c91b23b5227920c556c363bf Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 11 Oct 2021 16:41:37 +0200 Subject: [PATCH] block: use bdev_nr_bytes instead of open coding it in blkdev_fallocate Use the proper helper to read the block device size. Signed-off-by: Christoph Hellwig Reviewed-by: Kees Cook Reviewed-by: Jan Kara Reviewed-by: Chaitanya Kulkarni --- block/fops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/fops.c b/block/fops.c index 7bb9581a146c..a6a4d412720c 100644 --- a/block/fops.c +++ b/block/fops.c @@ -548,7 +548,7 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start, return -EOPNOTSUPP; /* Don't go off the end of the device. */ - isize = i_size_read(bdev->bd_inode); + isize = bdev_nr_bytes(bdev); if (start >= isize) return -EINVAL; if (end >= isize) { -- 2.50.1