Skip to content

Commit ae95c46

Browse files
digetxjoergroedel
authored andcommitted
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>
1 parent 4f821c1 commit ae95c46

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

drivers/iommu/tegra-gart.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,6 @@ static int tegra_gart_probe(struct platform_device *pdev)
411411
struct device *dev = &pdev->dev;
412412
int ret;
413413

414-
if (gart_handle)
415-
return -EIO;
416-
417414
BUILD_BUG_ON(PAGE_SHIFT != GART_PAGE_SHIFT);
418415

419416
/* the GART memory aperture is required */
@@ -448,8 +445,7 @@ static int tegra_gart_probe(struct platform_device *pdev)
448445
ret = iommu_device_register(&gart->iommu);
449446
if (ret) {
450447
dev_err(dev, "Failed to register IOMMU\n");
451-
iommu_device_sysfs_remove(&gart->iommu);
452-
return ret;
448+
goto remove_sysfs;
453449
}
454450

455451
gart->dev = &pdev->dev;
@@ -463,7 +459,8 @@ static int tegra_gart_probe(struct platform_device *pdev)
463459
gart->savedata = vmalloc(array_size(sizeof(u32), gart->page_count));
464460
if (!gart->savedata) {
465461
dev_err(dev, "failed to allocate context save area\n");
466-
return -ENOMEM;
462+
ret = -ENOMEM;
463+
goto unregister_iommu;
467464
}
468465

469466
platform_set_drvdata(pdev, gart);
@@ -472,6 +469,13 @@ static int tegra_gart_probe(struct platform_device *pdev)
472469
gart_handle = gart;
473470

474471
return 0;
472+
473+
unregister_iommu:
474+
iommu_device_unregister(&gart->iommu);
475+
remove_sysfs:
476+
iommu_device_sysfs_remove(&gart->iommu);
477+
478+
return ret;
475479
}
476480

477481
static const struct dev_pm_ops tegra_gart_pm_ops = {

0 commit comments

Comments
 (0)