[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180508181700.5169-6-digetx@gmail.com>
Date: Tue, 8 May 2018 21:16:56 +0300
From: Dmitry Osipenko <digetx@...il.com>
To: Joerg Roedel <joro@...tes.org>,
Thierry Reding <thierry.reding@...il.com>,
Jonathan Hunter <jonathanh@...dia.com>
Cc: linux-tegra@...r.kernel.org, iommu@...ts.linux-foundation.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v1 5/9] iommu/tegra: gart: Clean up driver probe failure unwinding
Properly clean up allocated resources on driver probe failure.
Signed-off-by: Dmitry Osipenko <digetx@...il.com>
---
drivers/iommu/tegra-gart.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
index 08e0de4087d1..39305224c48d 100644
--- a/drivers/iommu/tegra-gart.c
+++ b/drivers/iommu/tegra-gart.c
@@ -466,8 +466,7 @@ static int tegra_gart_probe(struct platform_device *pdev)
ret = iommu_device_register(&gart->iommu);
if (ret) {
dev_err(dev, "Failed to register IOMMU\n");
- iommu_device_sysfs_remove(&gart->iommu);
- return ret;
+ goto remove_sysfs;
}
gart->dev = &pdev->dev;
@@ -483,7 +482,8 @@ static int tegra_gart_probe(struct platform_device *pdev)
gart->savedata = vmalloc(sizeof(u32) * gart->page_count);
if (!gart->savedata) {
dev_err(dev, "failed to allocate context save area\n");
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto iommu_unregister;
}
platform_set_drvdata(pdev, gart);
@@ -493,6 +493,13 @@ static int tegra_gart_probe(struct platform_device *pdev)
tegra_mc_register_gart(&gart->mc_gart_handle);
return 0;
+
+iommu_unregister:
+ iommu_device_unregister(&gart->iommu);
+remove_sysfs:
+ iommu_device_sysfs_remove(&gart->iommu);
+
+ return ret;
}
static const struct dev_pm_ops tegra_gart_pm_ops = {
--
2.17.0
Powered by blists - more mailing lists