]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 1 Jun 2026 15:54:53 +0000 (17:54 +0200)
[ Upstream commit 85686c72966c5ee637893f124ddb31a1cace7bee ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/host/pci.c

index 6d522c52dca674bdd93130c6aff1624fd6b20275..5b998db940bd6d2a76b6e6fd0ad2101e00561650 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) {