iommu/amd: Fix error path in amd_iommu_probe_device()
Subsystems (2)
Vasant Hegde
maintainerPATCH 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.
---
---
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
@@ -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
Jörg Rödel
maintainerQuoted 14 lines · Vasant Hegde
Currently, the error path of
amd_iommu_probe_device()unconditionally referencesdev_data, which may not be initialized if an early failure occurs (likeiommu_init_device()fails).Move the
out_errlabel to ensure the function exits immediately on failure without accessing potentially uninitializeddev_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]>Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>Signed-off-by Vasant Hegde <[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