[PATCH v1 1/1] nvme: zns: cap zone report nr_zones by DMA buffer size

Christoph Hellwig hch at lst.de
Thu Jun 25 04:59:09 PDT 2026


On Wed, Jun 24, 2026 at 01:53:40PM +0800, Xixin Liu wrote:
> With Partial Report (PR=1), the Number of Zones (NZ) field in the report
> header must equal the number of zone descriptors fully transferred in the
> DMA buffer (ZNS Command Set Specification Rev 1.2, section 3.4.2).
> 
> nvme_ns_report_zones() does not cap the parse loop by max_in_buf derived
> from buflen.  Cap nz with min3() over the device-reported count, nr_zones -
> zone_idx, and max_in_buf.
> 
> Signed-off-by: Xixin Liu <liuxixin at kylinos.cn>
> ---
>  drivers/nvme/host/zns.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
> index 8ed1b6a33454..2a152e87bd76 100644
> --- a/drivers/nvme/host/zns.c
> +++ b/drivers/nvme/host/zns.c
> @@ -155,7 +155,8 @@ static int nvme_zone_parse_entry(struct nvme_ns *ns,
>  	struct blk_zone zone = { };
>  
>  	if ((entry->zt & 0xf) != NVME_ZONE_TYPE_SEQWRITE_REQ) {
> -		dev_err(ns->ctrl->device, "invalid zone type %#x\n", entry->zt);
> +		dev_err(ns->ctrl->device, "invalid zone type %#x at zone %u\n",
> +			entry->zt, idx);
>  		return -EINVAL;
>  	}

This looks fine, but unrelated.  Please split it into a separate patch.

The rest looks good as well.



More information about the Linux-nvme mailing list