]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
vfio/spapr/nvlink2: Skip unpinning pages on error exit
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Mon, 23 Dec 2019 01:09:27 +0000 (12:09 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Feb 2020 07:38:23 +0000 (08:38 +0100)
commitf9df37019ed3b1ca5903813dd3a9687af5967ea8
tree56e76ad9eec2ec532ab2c6764067e0d73be97624
parent42dbab0ca8efcc30859b2ec15b12c8bf85a00de2
vfio/spapr/nvlink2: Skip unpinning pages on error exit

[ Upstream commit 338b4e10f939a71194d8ecef7ece205a942cec05 ]

The nvlink2 subdriver for IBM Witherspoon machines preregisters
GPU memory in the IOMMI API so KVM TCE code can map this memory
for DMA as well. This is done by mm_iommu_newdev() called from
vfio_pci_nvgpu_regops::mmap.

In an unlikely event of failure the data->mem remains NULL and
since mm_iommu_put() (which unregisters the region and unpins memory
if that was regular memory) does not expect mem=NULL, it should not be
called.

This adds a check to only call mm_iommu_put() for a valid data->mem.

Fixes: 7f92891778df ("vfio_pci: Add NVIDIA GV100GL [Tesla V100 SXM2] subdriver")
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/vfio/pci/vfio_pci_nvlink2.c