All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] iommu/vt-d: Fix error handling in sva enable/disable paths
@ 2023-02-08  5:15 Lu Baolu
  2023-02-09  2:23 ` Tian, Kevin
  0 siblings, 1 reply; 2+ messages in thread
From: Lu Baolu @ 2023-02-08  5:15 UTC (permalink / raw)
  To: iommu
  Cc: Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian,
	linux-kernel, Lu Baolu

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")
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
 drivers/iommu/intel/iommu.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index a049178cd9f8..36d1867159d7 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -4650,8 +4650,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;
 }
@@ -4663,8 +4667,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;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH 1/1] iommu/vt-d: Fix error handling in sva enable/disable paths
  2023-02-08  5:15 [PATCH 1/1] iommu/vt-d: Fix error handling in sva enable/disable paths Lu Baolu
@ 2023-02-09  2:23 ` Tian, Kevin
  0 siblings, 0 replies; 2+ messages in thread
From: Tian, Kevin @ 2023-02-09  2:23 UTC (permalink / raw)
  To: Lu Baolu, iommu; +Cc: Joerg Roedel, Will Deacon, Robin Murphy, linux-kernel

> From: Lu Baolu <baolu.lu@linux.intel.com>
> Sent: Wednesday, February 8, 2023 1:16 PM
> 
> 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")
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>

Reviewed-by: Kevin Tian <kevin.tian@intel.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-09  2:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-08  5:15 [PATCH 1/1] iommu/vt-d: Fix error handling in sva enable/disable paths Lu Baolu
2023-02-09  2:23 ` Tian, Kevin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.