block: use bdev_nr_bytes instead of open coding it in blkdev_fallocate
authorChristoph Hellwig <hch@lst.de>
Mon, 18 Oct 2021 10:11:24 +0000 (12:11 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 18 Oct 2021 20:43:23 +0000 (14:43 -0600)
Use the proper helper to read the block device size.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://lore.kernel.org/r/20211018101130.1838532-25-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/fops.c

index 2c43e493e37c656f943252073b081ada0035672b..2ae8a7bd2b84acada0156f10b175ab8710e5c94c 100644 (file)
@@ -535,7 +535,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) {