]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
nvme-pci: handle changing device dma map requirements
authorKeith Busch <kbusch@kernel.org>
Wed, 4 Feb 2026 14:29:11 +0000 (06:29 -0800)
committerKeith Busch <kbusch@kernel.org>
Thu, 5 Feb 2026 15:29:10 +0000 (07:29 -0800)
commit071be3b0b6575d45be9df9c5b612f5882bfc5e88
tree736483bafbd38b8887f562b7e6f4e5eba8ff19cc
parent4da7c5c3ec34d839bba6e035c3d05c447a2f9d4f
nvme-pci: handle changing device dma map requirements

The initial state of dma_needs_unmap may be false, but change to true
while mapping the data iterator. Enabling swiotlb is one such case that
can change the result. The nvme driver needs to save the mapped dma
vectors to be unmapped later, so allocate as needed during iteration
rather than assume it was always allocated at the beginning. This fixes
a NULL dereference from accessing an uninitialized dma_vecs when the
device dma unmapping requirements change mid-iteration.

Fixes: b8b7570a7ec8 ("nvme-pci: fix dma unmapping when using PRPs and not using the IOVA mapping")
Link: https://lore.kernel.org/linux-nvme/20260202125738.1194899-1-pradeep.pragallapati@oss.qualcomm.com/
Reported-by: Pradeep P V K <pradeep.pragallapati@oss.qualcomm.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/host/pci.c