block: fix integer overflow in __blkdev_sectors_to_bio_pages()

Fix possible integer overflow in __blkdev_sectors_to_bio_pages if
sector_t is 32-bit.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Fixes: 615d22a51c04 ("block: Fix __blkdev_issue_zeroout loop")
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Mikulas Patocka and committed by
Jens Axboe
09c2c359 dbec491b

+2 -2
+2 -2
block/blk-lib.c
··· 269 */ 270 static unsigned int __blkdev_sectors_to_bio_pages(sector_t nr_sects) 271 { 272 - sector_t bytes = (nr_sects << 9) + PAGE_SIZE - 1; 273 274 - return min(bytes >> PAGE_SHIFT, (sector_t)BIO_MAX_PAGES); 275 } 276 277 /**
··· 269 */ 270 static unsigned int __blkdev_sectors_to_bio_pages(sector_t nr_sects) 271 { 272 + sector_t pages = DIV_ROUND_UP_SECTOR_T(nr_sects, PAGE_SIZE / 512); 273 274 + return min(pages, (sector_t)BIO_MAX_PAGES); 275 } 276 277 /**