summaryrefslogtreecommitdiffstats
path: root/drivers/iommu/arm/arm-smmu/qcom_iommu.c
diff options
context:
space:
mode:
authorAmey Narkhede <ameynarkhede03@gmail.com>2021-06-08 22:15:59 +0530
committerWill Deacon <will@kernel.org>2021-06-08 17:53:13 +0100
commit249c9dc6aa0db74a0f7908efd04acf774e19b155 (patch)
treec3231d0ab16b168c08951ab6b289987b9256133f /drivers/iommu/arm/arm-smmu/qcom_iommu.c
parentab9a77a141cc14ed607b4bf7a83ab6b0057ae084 (diff)
downloadlinux-stable-249c9dc6aa0db74a0f7908efd04acf774e19b155.tar.gz
linux-stable-249c9dc6aa0db74a0f7908efd04acf774e19b155.tar.bz2
linux-stable-249c9dc6aa0db74a0f7908efd04acf774e19b155.zip
iommu/arm: Cleanup resources in case of probe error path
If device registration fails, remove sysfs attribute and if setting bus callbacks fails, unregister the device and cleanup the sysfs attribute. Signed-off-by: Amey Narkhede <ameynarkhede03@gmail.com> Link: https://lore.kernel.org/r/20210608164559.204023-1-ameynarkhede03@gmail.com Signed-off-by: Will Deacon <will@kernel.org>
Diffstat (limited to 'drivers/iommu/arm/arm-smmu/qcom_iommu.c')
-rw-r--r--drivers/iommu/arm/arm-smmu/qcom_iommu.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
index 4294abe389b2..b785d9fb7602 100644
--- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c
+++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
@@ -850,10 +850,12 @@ static int qcom_iommu_device_probe(struct platform_device *pdev)
ret = iommu_device_register(&qcom_iommu->iommu, &qcom_iommu_ops, dev);
if (ret) {
dev_err(dev, "Failed to register iommu\n");
- return ret;
+ goto err_sysfs_remove;
}
- bus_set_iommu(&platform_bus_type, &qcom_iommu_ops);
+ ret = bus_set_iommu(&platform_bus_type, &qcom_iommu_ops);
+ if (ret)
+ goto err_unregister_device;
if (qcom_iommu->local_base) {
pm_runtime_get_sync(dev);
@@ -862,6 +864,13 @@ static int qcom_iommu_device_probe(struct platform_device *pdev)
}
return 0;
+
+err_unregister_device:
+ iommu_device_unregister(&qcom_iommu->iommu);
+
+err_sysfs_remove:
+ iommu_device_sysfs_remove(&qcom_iommu->iommu);
+ return ret;
}
static int qcom_iommu_device_remove(struct platform_device *pdev)