diff mbox series

[1/2] iommu: fix memory leak of iopf

Message ID 20221021035147.15292-2-liulongfang@huawei.com (mailing list archive)
State New, archived
Headers show
Series fix the memory leak of iopf | expand

Commit Message

Longfang Liu Oct. 21, 2022, 3:51 a.m. UTC
In arm_smmu_init_queues(), if ARM_SMMU_FEAT_SVA and ARM_SMMU_FEAT_STALLS
are enabled, iopf will be allocated a queue memory, and after
arm_smmu_init_one_queue() processing fails, this part of iopf
memory is not released, and there is a memory leak problem.

Signed-off-by: Longfang Liu <liulongfang@huawei.com>
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Longfang Liu Nov. 2, 2022, 1:36 a.m. UTC | #1
kindly ping!
On 2022/10/21 11:51, Longfang Liu wrote:
> In arm_smmu_init_queues(), if ARM_SMMU_FEAT_SVA and ARM_SMMU_FEAT_STALLS
> are enabled, iopf will be allocated a queue memory, and after
> arm_smmu_init_one_queue() processing fails, this part of iopf
> memory is not released, and there is a memory leak problem.
> 
> Signed-off-by: Longfang Liu <liulongfang@huawei.com>
> ---
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> 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 b788a38d8fdf..a1db07bed6a9 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -2939,9 +2939,13 @@ static int arm_smmu_init_queues(struct arm_smmu_device *smmu)
>  	if (!(smmu->features & ARM_SMMU_FEAT_PRI))
>  		return 0;
>  
> -	return arm_smmu_init_one_queue(smmu, &smmu->priq.q, smmu->page1,
> +	ret = arm_smmu_init_one_queue(smmu, &smmu->priq.q, smmu->page1,
>  				       ARM_SMMU_PRIQ_PROD, ARM_SMMU_PRIQ_CONS,
>  				       PRIQ_ENT_DWORDS, "priq");
> +	if (ret)
> +		iopf_queue_free(smmu->evtq.iopf);
> +
> +	return ret;
>  }
>  
>  static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu)
>
diff mbox series

Patch

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 b788a38d8fdf..a1db07bed6a9 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -2939,9 +2939,13 @@  static int arm_smmu_init_queues(struct arm_smmu_device *smmu)
 	if (!(smmu->features & ARM_SMMU_FEAT_PRI))
 		return 0;
 
-	return arm_smmu_init_one_queue(smmu, &smmu->priq.q, smmu->page1,
+	ret = arm_smmu_init_one_queue(smmu, &smmu->priq.q, smmu->page1,
 				       ARM_SMMU_PRIQ_PROD, ARM_SMMU_PRIQ_CONS,
 				       PRIQ_ENT_DWORDS, "priq");
+	if (ret)
+		iopf_queue_free(smmu->evtq.iopf);
+
+	return ret;
 }
 
 static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu)