summaryrefslogtreecommitdiffstats
path: root/drivers/iommu
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>2014-03-14 14:00:56 +0100
committerLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>2015-01-16 17:03:04 +0100
commitb8f80bffd51f4ef029051d6898d9c2e3e5637dc3 (patch)
treedfb18ae7d3179fe5ea7052b4a4f1676a563125f2 /drivers/iommu
parentlinux 3.19-rc4 (diff)
downloadlinux-b8f80bffd51f4ef029051d6898d9c2e3e5637dc3.tar.xz
linux-b8f80bffd51f4ef029051d6898d9c2e3e5637dc3.zip
iommu/ipmmu-vmsa: Cleanup failures of ARM mapping creation or attachment
The ARM IOMMU mapping needs to be released when attaching the device fails. Add arm_iommu_release_mapping() to the error code path. This is safe to call with a NULL mapping, so no specific check is needed. Cleanup is also missing when failing to create a mapping. Jump to the error code path in that case instead of returning immediately. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/ipmmu-vmsa.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 748693192c20..034293ca4b9a 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -1090,7 +1090,8 @@ static int ipmmu_add_device(struct device *dev)
SZ_1G, SZ_2G);
if (IS_ERR(mapping)) {
dev_err(mmu->dev, "failed to create ARM IOMMU mapping\n");
- return PTR_ERR(mapping);
+ ret = PTR_ERR(mapping);
+ goto error;
}
mmu->mapping = mapping;
@@ -1106,6 +1107,7 @@ static int ipmmu_add_device(struct device *dev)
return 0;
error:
+ arm_iommu_release_mapping(mmu->mapping);
kfree(dev->archdata.iommu);
dev->archdata.iommu = NULL;
iommu_group_remove_device(dev);