Skip to contentSkip to conversation

iommu/amd: Fix error path in amd_iommu_probe_device()

PATCH In review Vasant Hegde 2 participants 2 messages Jan 16 – Jan 18

Subsystems (2)
lore
Share & tools
lore

Vasant Hegde

author maintainer
#0 lore raw

PATCH 1/1 iommu/amd: Fix error path in amd_iommu_probe_device()

Currently, the error path of amd_iommu_probe_device() unconditionally references dev_data, which may not be initialized if an early failure occurs (like iommu_init_device() fails).

Move the out_err label to ensure the function exits immediately on failure without accessing potentially uninitialized dev_data.

Fixes 19e5cc156cb ("iommu/amd: Enable support for up to 2K interrupts per function")
Cc Rakuram Eswaran <[email protected]>
Cc Jörg Rödel <[email protected]>

---
---
Joerg,
This code path needs some rework. We have to re-arrange PCI feature enablement properly. I will do it later along with other SVA related cleanup.

-Vasant

 drivers/iommu/amd/iommu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iommu/amd/iommu.c +1 -2
index d7f457338de7..2a3c9bb1c229 100644
@@ -2454,8 +2454,6 @@ static struct iommu_device *amd_iommu_probe_device(struct device *dev)
 		goto out_err;
 	}
 
-out_err:
-
 	iommu_completion_wait(iommu);
 
 	if (FEATURE_NUM_INT_REMAP_SUP_2K(amd_iommu_efr2))
@@ -2466,6 +2464,7 @@ static struct iommu_device *amd_iommu_probe_device(struct device *dev)
 	if (dev_is_pci(dev))
 		pci_prepare_ats(to_pci_dev(dev), PAGE_SHIFT);
 
+out_err:
 	return iommu_dev;
 }
 
Signature · 1 line
2.31.1
maintainer
#1 lore raw
Quoted 14 lines · Vasant Hegde

Currently, the error path of amd_iommu_probe_device() unconditionally references dev_data, which may not be initialized if an early failure occurs (like iommu_init_device() fails).

Move the out_err label to ensure the function exits immediately on failure without accessing potentially uninitialized dev_data.

Fixes 19e5cc156cb ("iommu/amd: Enable support for up to 2K interrupts per function")
Cc Rakuram Eswaran <[email protected]>
Cc Jörg Rödel <[email protected]>
Quoted 6 lines

---
---
Joerg,
This code path needs some rework. We have to re-arrange PCI feature enablement properly. I will do it later along with other SVA related cleanup.

Thanks Vasant. This patch is now applied for -rc.

-Joerg