From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: Re: [PATCH 05/11] block: Limit allocation of zone descriptors for report zones Date: Wed, 10 Oct 2018 15:27:14 +0200 Message-ID: <20181010132714.GE22273@lst.de> References: <20181010015239.24930-1-damien.lemoal@wdc.com> <20181010015239.24930-6-damien.lemoal@wdc.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20181010015239.24930-6-damien.lemoal@wdc.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: Damien Le Moal Cc: Jens Axboe , "Martin K . Petersen" , Mike Snitzer , linux-block@vger.kernel.org, dm-devel@redhat.com, linux-scsi@vger.kernel.org, Christoph Hellwig , Matias Bjorling List-Id: linux-scsi@vger.kernel.org > + unsigned int nr_zones; > int ret; > > if (!argp) > @@ -355,8 +356,9 @@ 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; > + nr_zones = blkdev_nr_zones(bdev); > + if (rep.nr_zones > nr_zones) > + rep.nr_zones = nr_zones; This could be further simplified using min_t, but othewise it looks fine to me: Reviewed-by: Christoph Hellwig