Re: [RFC PATCH 5/6] iommu: Support mm PASID 1:1 with sva domain

From: Yanfei Xu
Date: Mon Jul 17 2023 - 04:48:17 EST


Hi Tina,

On 7/7/2023 9:34 AM, Tina Zhang wrote:
@@ -33,9 +34,18 @@ static int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min, ioasid_t ma
goto out;
}
+ iommu_mm = kzalloc(sizeof(struct iommu_mm_data), GFP_KERNEL);
+ if (!iommu_mm) {
+ ret = -ENOMEM;
+ goto out;
+ }
+ mm->iommu_mm = iommu_mm;
+
ret = ida_alloc_range(&iommu_global_pasid_ida, min, max, GFP_KERNEL);
- if (ret < min)
+ if (ret < min) {
+ kfree(iommu_mm);
goto out;

Once pasid allocation fails at this part, we should reassign the mm->iommu_mm back to default value, or it will keep a unavailable pointer, right?

Thanks,
Yanfei
+ }
mm_set_pasid(mm, ret);
ret = 0;
out: