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