]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iommu/amd: Handle error path in amd_iommu_probe_device()
authorVasant Hegde <vasant.hegde@amd.com>
Wed, 28 Aug 2024 11:10:25 +0000 (11:10 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Oct 2024 14:32:40 +0000 (16:32 +0200)
[ Upstream commit 293aa9ec694e633bff83ab93715a2684e15fe214 ]

Do not try to set max_pasids in error path as dev_data is not allocated.

Fixes: a0c47f233e68 ("iommu/amd: Introduce iommu_dev_data.max_pasids")
Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
Reviewed-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Link: https://lore.kernel.org/r/20240828111029.5429-5-vasant.hegde@amd.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iommu/amd/iommu.c

index b19e8c0f48fa25f1594d983e2f17a23f7571c4a7..fc660d4b10ac8d40a249e0056ee8abd844a9a999 100644 (file)
@@ -2185,11 +2185,12 @@ static struct iommu_device *amd_iommu_probe_device(struct device *dev)
                dev_err(dev, "Failed to initialize - trying to proceed anyway\n");
                iommu_dev = ERR_PTR(ret);
                iommu_ignore_device(iommu, dev);
-       } else {
-               amd_iommu_set_pci_msi_domain(dev, iommu);
-               iommu_dev = &iommu->iommu;
+               goto out_err;
        }
 
+       amd_iommu_set_pci_msi_domain(dev, iommu);
+       iommu_dev = &iommu->iommu;
+
        /*
         * If IOMMU and device supports PASID then it will contain max
         * supported PASIDs, else it will be zero.
@@ -2201,6 +2202,7 @@ static struct iommu_device *amd_iommu_probe_device(struct device *dev)
                                             pci_max_pasids(to_pci_dev(dev)));
        }
 
+out_err:
        iommu_completion_wait(iommu);
 
        return iommu_dev;