]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
nvme-pci: fix dma_vecs leak on p2p memory
authorKeith Busch <kbusch@kernel.org>
Wed, 20 May 2026 01:03:44 +0000 (18:03 -0700)
committerKeith Busch <kbusch@kernel.org>
Thu, 21 May 2026 14:48:58 +0000 (07:48 -0700)
We don't unmap P2P memory, so we don't need to track it. The dma_vec
allocation was getting leaked on the completion.

Fixes: b8b7570a7ec87 ("nvme-pci: fix dma unmapping when using PRPs and not using the IOVA mapping")
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/host/pci.c

index 139a10cd687f9a8b5b3294fb497cb637499daab2..f423f17184398442fa2865cd2fda939a6d63be0c 100644 (file)
@@ -966,7 +966,8 @@ static bool nvme_pci_prp_save_mapping(struct request *req,
 {
        struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
 
-       if (dma_use_iova(&iod->dma_state) || !dma_need_unmap(dma_dev))
+       if (dma_use_iova(&iod->dma_state) || !dma_need_unmap(dma_dev) ||
+           (iod->flags & IOD_DATA_P2P))
                return true;
 
        if (!iod->nr_dma_vecs) {