From 528c99691b4ec6180be29418c2e89e59199e7aa3 Mon Sep 17 00:00:00 2001 From: vkakani Date: Tue, 29 May 2018 15:41:04 +0530 Subject: [PATCH] ARM: SMMU: clear page table ops of attached device incase of error during dynamic attach, added smmu attach device cleanup along with free page table ops Change-Id: Id8984d05002700014307a905fc7166702fa64a7d Signed-off-by: vkakani --- drivers/iommu/arm-smmu.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 6317478916ef..56f2980adc28 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -2256,8 +2256,17 @@ static int arm_smmu_attach_dynamic(struct iommu_domain *domain, smmu_domain->pgtbl_ops = pgtbl_ops; ret = 0; out: - if (ret) + if (ret) { free_io_pgtable_ops(pgtbl_ops); + /* unassign any freed page table memory */ + if (arm_smmu_is_master_side_secure(smmu_domain)) { + arm_smmu_secure_domain_lock(smmu_domain); + arm_smmu_secure_pool_destroy(smmu_domain); + arm_smmu_unassign_table(smmu_domain); + arm_smmu_secure_domain_unlock(smmu_domain); + } + smmu_domain->pgtbl_ops = NULL; + } mutex_unlock(&smmu->attach_lock); return ret;