[PATCH 2/2] iommu: fix smmu initialization memory leak problem
Longfang Liu
liulongfang at huawei.com
Thu Oct 20 20:51:47 PDT 2022
When iommu_device_register() in arm_smmu_device_probe() fails,
in addition to sysfs needs to be deleted, device should also
be disabled, and the memory of iopf needs to be released to
prevent memory leak of iopf.
Signed-off-by: Longfang Liu <liulongfang at huawei.com>
---
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index a1db07bed6a9..c70defb0c866 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -3816,11 +3816,16 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
ret = iommu_device_register(&smmu->iommu, &arm_smmu_ops, dev);
if (ret) {
dev_err(dev, "Failed to register iommu\n");
- iommu_device_sysfs_remove(&smmu->iommu);
- return ret;
+ goto err_sysfs_remove;
}
return 0;
+
+err_sysfs_remove:
+ iommu_device_sysfs_remove(&smmu->iommu);
+ arm_smmu_device_disable(smmu);
+ iopf_queue_free(smmu->evtq.iopf);
+ return ret;
}
static int arm_smmu_device_remove(struct platform_device *pdev)
--
2.24.0
More information about the linux-arm-kernel
mailing list