summaryrefslogtreecommitdiffstats
path: root/drivers/iommu/tegra-gart.c
diff options
context:
space:
mode:
authorDmitry Osipenko <digetx@gmail.com>2018-12-12 21:38:45 +0100
committerJoerg Roedel <jroedel@suse.de>2019-01-16 13:54:09 +0100
commitae95c46dbed56af0e1d106865801bf06e1762c2c (patch)
tree183b152c7e165c4ac7aa858436414d4da9f6fecc /drivers/iommu/tegra-gart.c
parentiommu/tegra: gart: Remove pr_fmt and clean up includes (diff)
downloadlinux-ae95c46dbed56af0e1d106865801bf06e1762c2c.tar.xz
linux-ae95c46dbed56af0e1d106865801bf06e1762c2c.zip
iommu/tegra: gart: Clean up driver probe errors handling
Properly clean up allocated resources on the drivers probe failure and remove unneeded checks. Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu/tegra-gart.c')
-rw-r--r--drivers/iommu/tegra-gart.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
index ff75cf60117b..1cd470b2beea 100644
--- a/drivers/iommu/tegra-gart.c
+++ b/drivers/iommu/tegra-gart.c
@@ -411,9 +411,6 @@ static int tegra_gart_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
int ret;
- if (gart_handle)
- return -EIO;
-
BUILD_BUG_ON(PAGE_SHIFT != GART_PAGE_SHIFT);
/* the GART memory aperture is required */
@@ -448,8 +445,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;
@@ -463,7 +459,8 @@ static int tegra_gart_probe(struct platform_device *pdev)
gart->savedata = vmalloc(array_size(sizeof(u32), gart->page_count));
if (!gart->savedata) {
dev_err(dev, "failed to allocate context save area\n");
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto unregister_iommu;
}
platform_set_drvdata(pdev, gart);
@@ -472,6 +469,13 @@ static int tegra_gart_probe(struct platform_device *pdev)
gart_handle = gart;
return 0;
+
+unregister_iommu:
+ 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 = {