diff --git a/block/blk-zoned.c b/block/blk-zoned.c index 32e377f755d81b6ab41e57f913cbd015b669189a..bb4ed69f917feb7553ee8d2a8d099fb67f4a0c48 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -355,8 +355,7 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode, if (!rep.nr_zones) return -EINVAL; - if (rep.nr_zones > INT_MAX / sizeof(struct blk_zone)) - return -ERANGE; + rep.nr_zones = min(blkdev_nr_zones(bdev), rep.nr_zones); zones = kvmalloc_array(rep.nr_zones, sizeof(struct blk_zone), GFP_KERNEL | __GFP_ZERO);