blob: 76be7e9027e1f49023cb06dd8668a922ae729893 [file] [log] [blame]
From 3dd1dd58e7390281978dfab0addb6285a83b3719 Mon Sep 17 00:00:00 2001
From: Alexey Kardashevskiy <>
Date: Mon, 23 Dec 2019 12:09:27 +1100
Subject: [PATCH] vfio/spapr/nvlink2: Skip unpinning pages on error exit
commit 338b4e10f939a71194d8ecef7ece205a942cec05 upstream.
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
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
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 <>
Signed-off-by: Alex Williamson <>
Signed-off-by: Paul Gortmaker <>
diff --git a/drivers/vfio/pci/vfio_pci_nvlink2.c b/drivers/vfio/pci/vfio_pci_nvlink2.c
index 50fe3c4f7feb..a22340c5e7d0 100644
--- a/drivers/vfio/pci/vfio_pci_nvlink2.c
+++ b/drivers/vfio/pci/vfio_pci_nvlink2.c
@@ -97,8 +97,10 @@ static void vfio_pci_nvgpu_release(struct vfio_pci_device *vdev,
/* If there were any mappings at all... */
if (data->mm) {
- ret = mm_iommu_put(data->mm, data->mem);
- WARN_ON(ret);
+ if (data->mem) {
+ ret = mm_iommu_put(data->mm, data->mem);
+ WARN_ON(ret);
+ }