Skip to content

Commit 1bb94ff

Browse files
Christoph Hellwigaxboe
authored andcommitted
nvme-pci: don't allocate dma_vec for IOVA mappings
Not only do IOVA mappings no need the separate dma_vec tracking, it also won't free it and thus leak the allocations. Fixes: b8b7570 ("nvme-pci: fix dma unmapping when using PRPs and not using the IOVA mapping") Reported-by: Klara Modin <klarasmodin@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Tested-by: Klara Modin <klarasmodin@gmail.com> Link: https://lore.kernel.org/r/20250711112250.633269-1-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 8b428f4 commit 1bb94ff

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/nvme/host/pci.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ static bool nvme_pci_prp_iter_next(struct request *req, struct device *dma_dev,
745745
return true;
746746
if (!blk_rq_dma_map_iter_next(req, dma_dev, &iod->dma_state, iter))
747747
return false;
748-
if (dma_need_unmap(dma_dev)) {
748+
if (!dma_use_iova(&iod->dma_state) && dma_need_unmap(dma_dev)) {
749749
iod->dma_vecs[iod->nr_dma_vecs].addr = iter->addr;
750750
iod->dma_vecs[iod->nr_dma_vecs].len = iter->len;
751751
iod->nr_dma_vecs++;
@@ -763,7 +763,7 @@ static blk_status_t nvme_pci_setup_data_prp(struct request *req,
763763
unsigned int prp_len, i;
764764
__le64 *prp_list;
765765

766-
if (dma_need_unmap(nvmeq->dev->dev)) {
766+
if (!dma_use_iova(&iod->dma_state) && dma_need_unmap(nvmeq->dev->dev)) {
767767
iod->dma_vecs = mempool_alloc(nvmeq->dev->dmavec_mempool,
768768
GFP_ATOMIC);
769769
if (!iod->dma_vecs)

0 commit comments

Comments
 (0)