提交 b8f80bff 编写于 作者: L Laurent Pinchart

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: NLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
上级 eaa27f34
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册