[PATCHv3 2/2] nvme-pci: fix dma mapping leak on data setup error

Christoph Hellwig hch at lst.de
Thu May 21 01:23:18 PDT 2026


On Wed, May 20, 2026 at 10:49:53AM -0700, Keith Busch wrote:
> +static void nvme_unmap_iter(struct request *req, struct blk_dma_iter *iter,
> +			    struct dma_iova_state *state)
> +{
> +	struct nvme_queue *nvmeq = req->mq_hctx->driver_data;
> +	struct device *dev = nvmeq->dev->dev;
> +
> +	if (!blk_rq_dma_unmap(req, dev, state, iter->len, iter->p2pdma.map)) {
> +		unsigned int attrs = 0;
> +
> +		if (iter->p2pdma.map == PCI_P2PDMA_MAP_THRU_HOST_BRIDGE)
> +			attrs |= DMA_ATTR_MMIO;
> +
> +		dma_unmap_phys(dev, iter->addr, iter->len, rq_dma_dir(req),
> +			       attrs);
> +	}

At some point this might be worth lifting to the block layer, but we
can defer that until needed.

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch at lst.de>




More information about the Linux-nvme mailing list