]> git.baikalelectronics.ru Git - kernel.git/commitdiff
iommu/exynos: Handle failed IOMMU device registration properly
authorSam Protsenko <semen.protsenko@linaro.org>
Thu, 14 Jul 2022 16:55:46 +0000 (19:55 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:24:07 +0000 (14:24 +0200)
[ Upstream commit dd69d9e5125774939c831e45980284b2321d4e82 ]

If iommu_device_register() fails in exynos_sysmmu_probe(), the previous
calls have to be cleaned up. In this case, the iommu_device_sysfs_add()
should be cleaned up, by calling its remove counterpart call.

Fixes: 2e3f523a7355 ("iommu/exynos: Make use of iommu_device_register interface")
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Link: https://lore.kernel.org/r/20220714165550.8884-3-semen.protsenko@linaro.org
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iommu/exynos-iommu.c

index 939ffa768986706fa6791c90dd05c79805ded2ce..f96acc3525e8f7e5a54b43829188277b6468a707 100644 (file)
@@ -630,7 +630,7 @@ static int exynos_sysmmu_probe(struct platform_device *pdev)
 
        ret = iommu_device_register(&data->iommu, &exynos_iommu_ops, dev);
        if (ret)
-               return ret;
+               goto err_iommu_register;
 
        platform_set_drvdata(pdev, data);
 
@@ -657,6 +657,10 @@ static int exynos_sysmmu_probe(struct platform_device *pdev)
        pm_runtime_enable(dev);
 
        return 0;
+
+err_iommu_register:
+       iommu_device_sysfs_remove(&data->iommu);
+       return ret;
 }
 
 static int __maybe_unused exynos_sysmmu_suspend(struct device *dev)