]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
nvme-pci: fix dma mapping leak on data setup error
authorKeith Busch <kbusch@kernel.org>
Tue, 19 May 2026 20:01:57 +0000 (13:01 -0700)
committerKeith Busch <kbusch@kernel.org>
Thu, 21 May 2026 14:49:05 +0000 (07:49 -0700)
commit1bf86336e4b6cf40873fda47a7fe191446864937
tree0178f07e2dd83e8654c8f6c19cb23fb1996e9b45
parent85686c72966c5ee637893f124ddb31a1cace7bee
nvme-pci: fix dma mapping leak on data setup error

We're leaking the initial DMA mapping during iteration if we fail to
allocate the tracking descriptor for both PRP and SGL. Unmap the
iterator directly; we can't use the existing unmap helper because it
depends on the tracking descriptor being successfully allocated, so a
new one for an in-use iterator is provided.

The mappings were also leaking when the driver detects an invalid
bio_vec when mapping PRPs, so fix that too.

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