Commit 2e85fbaf authored by Damien Le Moal's avatar Damien Le Moal Committed by Jens Axboe

block: Limit allocation of zone descriptors for report zones

There is no point in allocating more zone descriptors than the number of
zones a block device has for doing a zone report. Avoid doing that in
blkdev_report_zones_ioctl() by limiting the number of zone decriptors
allocated internally to process the user request.
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent a91e1380
...@@ -355,8 +355,7 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode, ...@@ -355,8 +355,7 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
if (!rep.nr_zones) if (!rep.nr_zones)
return -EINVAL; return -EINVAL;
if (rep.nr_zones > INT_MAX / sizeof(struct blk_zone)) rep.nr_zones = min(blkdev_nr_zones(bdev), rep.nr_zones);
return -ERANGE;
zones = kvmalloc_array(rep.nr_zones, sizeof(struct blk_zone), zones = kvmalloc_array(rep.nr_zones, sizeof(struct blk_zone),
GFP_KERNEL | __GFP_ZERO); GFP_KERNEL | __GFP_ZERO);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment