On Sat, Jul 04, 2026 at 05:46:44AM +0100, Adrián Larumbe wrote:
> This check is being already carried out further down the call stack inside
> drm_gpuvm_sm_map -> drm_gpuvm_range_valid, but it's best to fail early in
> the driver before GPUVM functions are invoked so that we won't waste time
> allocating vm_bind context resources.
> 
> Reported-by: Sashiko <[email protected]>
> Closes: 
> https://sashiko.dev/#/message/20260623204220.CDB1B1F000E9%40smtp.kernel.org
> Fixes: 12cf826bf1dd ("drm/panthor: Support sparse mappings")
> Signed-off-by: Adrián Larumbe <[email protected]>

Reviewed-by: Liviu Dudau <[email protected]>

Best regards,
Liviu

> ---
>  drivers/gpu/drm/panthor/panthor_mmu.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c 
> b/drivers/gpu/drm/panthor/panthor_mmu.c
> index 31cc57029c12..163231c1703d 100644
> --- a/drivers/gpu/drm/panthor/panthor_mmu.c
> +++ b/drivers/gpu/drm/panthor/panthor_mmu.c
> @@ -2975,12 +2975,16 @@ panthor_vm_bind_prepare_op_ctx(struct drm_file *file,
>  {
>       ssize_t vm_pgsz = panthor_vm_page_size(vm);
>       struct drm_gem_object *gem;
> +     u64 end;
>       int ret;
>  
>       /* Aligned on page size. */
>       if (!IS_ALIGNED(op->va | op->size | op->bo_offset, vm_pgsz))
>               return -EINVAL;
>  
> +     if (check_add_overflow(op->va, op->size, &end))
> +             return -EINVAL;
> +
>       switch (op->flags & DRM_PANTHOR_VM_BIND_OP_TYPE_MASK) {
>       case DRM_PANTHOR_VM_BIND_OP_TYPE_MAP:
>               if (!(op->flags & DRM_PANTHOR_VM_BIND_OP_MAP_SPARSE)) {
> 
> -- 
> 2.55.0
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

Reply via email to