[PATCH V1] nvme-pci: Fix NULL pointer dereference in nvme_pci_prp_iter_next
Keith Busch
kbusch at kernel.org
Mon Feb 2 09:18:12 PST 2026
On Mon, Feb 02, 2026 at 06:27:38PM +0530, Pradeep P V K wrote:
> @@ -720,6 +720,7 @@ static void nvme_free_prps(struct request *req, unsigned int attrs)
> dma_unmap_phys(nvmeq->dev->dev, iod->dma_vecs[i].addr,
> iod->dma_vecs[i].len, rq_dma_dir(req), attrs);
> mempool_free(iod->dma_vecs, nvmeq->dev->dmavec_mempool);
> + iod->dma_vecs = NULL;
> }
>
> static void nvme_free_sgls(struct request *req, struct nvme_sgl_desc *sge,
> @@ -825,7 +826,7 @@ static bool nvme_pci_prp_iter_next(struct request *req, struct device *dma_dev,
> return true;
> if (!blk_rq_dma_map_iter_next(req, dma_dev, iter))
> return false;
> - if (!dma_use_iova(&iod->dma_state) && dma_need_unmap(dma_dev)) {
> + if (iod->dma_vecs && !dma_use_iova(&iod->dma_state) && dma_need_unmap(dma_dev)) {
So the return of dma_need_unmap() may change after any call to
dma_map_*? Does it only go from false -> true, and never back to false?
Since we didn't allocate the dma_vecs here, doesn't that mean the
completion side is leaking the mapping?
More information about the Linux-nvme
mailing list