]> 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>
Thu, 25 Aug 2022 09:18:03 +0000 (11:18 +0200)
[ Upstream commit 44c709a474d23b5fac5fe7da9d10c063c6b9c2d0 ]

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: 38aefe36a546 ("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 55ed857f804f7aa5dffbedd57dcbf4ca0903e2c3..31a9b9885653fa611209a14e18fb326223d99467 100644 (file)
@@ -635,7 +635,7 @@ static int exynos_sysmmu_probe(struct platform_device *pdev)
 
        ret = iommu_device_register(&data->iommu);
        if (ret)
-               return ret;
+               goto err_iommu_register;
 
        platform_set_drvdata(pdev, data);
 
@@ -662,6 +662,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)