>   *
>   * Returns 0 on success and < 0 on error.
> @@ -28,6 +28,9 @@ int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t 
> min, ioasid_t max)
>       int ret = 0;
>       ioasid_t pasid;
>  
> +     if (mm != current->mm)
> +             return -EINVAL;
> +

Why not remove the parameter entirely?

> @@ -2989,8 +2990,11 @@ iommu_sva_bind_device(struct device *dev, struct 
> mm_struct *mm, unsigned int fla
>               return ERR_PTR(-ENODEV);
>  
>       /* Supervisor SVA does not need the current mm */
> -     if ((flags & IOMMU_SVA_BIND_SUPERVISOR) && mm)
> -             return ERR_PTR(-EINVAL);
> +     if (!(flags & IOMMU_SVA_BIND_SUPERVISOR)) {
> +             mm = get_task_mm(current);
> +             if (!mm)
> +                     return ERR_PTR(-EINVAL);
> +     }

I don't see why we need the reference.  I think we should just stop
passing the mm to ->sva_bind and let the low-level driver deal with
any reference to current->mm where needed.

Reply via email to