Skip to contentSkip to conversation

iommu/arm-smmu-v3: Fix incorrect return in arm_smmu_attach_dev

PATCH Applied Qinxin Xia 2 participants 2 messages Apr 22, 2025 – May 6, 2025

Subsystems (2)
lore
Share & tools
lore

Qinxin Xia

author
#0 lore raw

PATCH 1/1 iommu/arm-smmu-v3: Fix incorrect return in arm_smmu_attach_dev

An error is introduced in commit '48e7b8e284e5'. When the smmu does not match with domain,an error code is not returned.
An example of an error scenario: In vfio_iommu_type1_attach_group, vfio will try to match an existing compatible domain. During this process, iommu invokes the attach_dev interface.The mismatched dev and domain does not return an error code as expected.
As a result, an exception occurs when the vfio operates the smmu.

Fixes 48e7b8e284e5 ("iommu/arm-smmu-v3: Remove arm_smmu_domain_finalise() during attach")
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +1 -1
index 358072b4e293..cb2698325809 100644
@@ -2932,7 +2932,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
 	smmu = master->smmu;
 
 	if (smmu_domain->smmu != smmu)
-		return ret;
+		return -EINVAL;
 
 	if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1) {
 		cdptr = arm_smmu_alloc_cd_ptr(master, IOMMU_NO_PASID);
Signature · 1 line
2.33.0
maintainer Applied
#1 lore raw
Quoted 9 lines · Qinxin Xia

An error is introduced in commit '48e7b8e284e5'. When the smmu does not match with domain,an error code is not returned.
An example of an error scenario: In vfio_iommu_type1_attach_group, vfio will try to match an existing compatible domain. During this process, iommu invokes the attach_dev interface.The mismatched dev and domain does not return an error code as expected.
As a result, an exception occurs when the vfio operates the smmu.

[...]

Applied to iommu (arm/smmu/updates), thanks!

[1/1] iommu/arm-smmu-v3: Fix incorrect return in arm_smmu_attach_dev

      https://git.kernel.org/iommu/c/be5a2d3f8f97

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev