Skip to content

Commit 2e85fba

Browse files
damien-lemoalaxboe
authored andcommitted
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: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent a91e138 commit 2e85fba

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

block/blk-zoned.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,7 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
355355
if (!rep.nr_zones)
356356
return -EINVAL;
357357

358-
if (rep.nr_zones > INT_MAX / sizeof(struct blk_zone))
359-
return -ERANGE;
358+
rep.nr_zones = min(blkdev_nr_zones(bdev), rep.nr_zones);
360359

361360
zones = kvmalloc_array(rep.nr_zones, sizeof(struct blk_zone),
362361
GFP_KERNEL | __GFP_ZERO);

0 commit comments

Comments
 (0)