diff options
author | Lu Baolu <baolu.lu@linux.intel.com> | 2023-02-16 21:08:13 +0800 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2023-02-16 14:43:04 +0100 |
commit | 60b1daa3b168fbc648ae2ad28a84759223e49e18 (patch) | |
tree | 9e45eb444d0961bd5422bc4a175b93d364958003 /drivers/iommu | |
parent | d8a7c0cf05a2ac79d3cbd0c0ed7d01ec01f75980 (diff) | |
download | linux-60b1daa3b168fbc648ae2ad28a84759223e49e18.tar.gz linux-60b1daa3b168fbc648ae2ad28a84759223e49e18.tar.bz2 linux-60b1daa3b168fbc648ae2ad28a84759223e49e18.zip |
iommu/vt-d: Fix error handling in sva enable/disable paths
Roll back all previous actions in error paths of intel_iommu_enable_sva()
and intel_iommu_disable_sva().
Fixes: d5b9e4bfe0d8 ("iommu/vt-d: Report prq to io-pgfault framework")
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/20230208051559.700109-1-baolu.lu@linux.intel.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu')
-rw-r--r-- | drivers/iommu/intel/iommu.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 691b306fada5..9107fac8c375 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4644,8 +4644,12 @@ static int intel_iommu_enable_sva(struct device *dev) return -EINVAL; ret = iopf_queue_add_device(iommu->iopf_queue, dev); - if (!ret) - ret = iommu_register_device_fault_handler(dev, iommu_queue_iopf, dev); + if (ret) + return ret; + + ret = iommu_register_device_fault_handler(dev, iommu_queue_iopf, dev); + if (ret) + iopf_queue_remove_device(iommu->iopf_queue, dev); return ret; } @@ -4657,8 +4661,12 @@ static int intel_iommu_disable_sva(struct device *dev) int ret; ret = iommu_unregister_device_fault_handler(dev); - if (!ret) - ret = iopf_queue_remove_device(iommu->iopf_queue, dev); + if (ret) + return ret; + + ret = iopf_queue_remove_device(iommu->iopf_queue, dev); + if (ret) + iommu_register_device_fault_handler(dev, iommu_queue_iopf, dev); return ret; } |