vfio/iommu_type1: Fix some sanity checks in detach group
authorKeqian Zhu <zhukeqian1@huawei.com>
Fri, 22 Jan 2021 09:26:35 +0000 (17:26 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Mar 2021 10:38:13 +0000 (11:38 +0100)
commitc0e73c1d6d9186ab861e3d461a77836071cff990
tree768711228192328e78fd9a2773b46484a7d2b8bb
parenta8fe0b750a9456b6318625d6d27d26c89a62efe1
vfio/iommu_type1: Fix some sanity checks in detach group

[ Upstream commit 4a19f37a3dd3f29997735e61b25ddad24b8abe73 ]

vfio_sanity_check_pfn_list() is used to check whether pfn_list and
notifier are empty when remove the external domain, so it makes a
wrong assumption that only external domain will use the pinning
interface.

Now we apply the pfn_list check when a vfio_dma is removed and apply
the notifier check when all domains are removed.

Fixes: a54eb55045ae ("vfio iommu type1: Add support for mediated devices")
Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/vfio/vfio_iommu_type1.c