[Intel-xe] [PATCH] drm/xe: Prevent null ptr dereference

Welty, Brian brian.welty at intel.com
Mon Nov 6 19:58:20 UTC 2023



On 11/3/2023 2:19 PM, Pallavi Mishra wrote:
> In scenarios where vm is not initialized, use xe_migrate
> to get the address.

Can you describe this scenario?
Is it legal to call xe_migrate_update_pgtables without a vm?
What code path does that?

Just trying to understand if shouldn't be instead returning an error if 
vm is NULL. Or that isn't some other driver bug.

-Brian


> 
> Signed-off-by: Pallavi Mishra <pallavi.mishra at intel.com>
> ---
>   drivers/gpu/drm/xe/xe_migrate.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c
> index e6a31f90ebdb..f79ec8e4ae4e 100644
> --- a/drivers/gpu/drm/xe/xe_migrate.c
> +++ b/drivers/gpu/drm/xe/xe_migrate.c
> @@ -1296,7 +1296,10 @@ xe_migrate_update_pgtables(struct xe_migrate *m,
>   
>   			xe_tile_assert(tile, pt_bo->size == SZ_4K);
>   
> -			addr = vm->pt_ops->pte_encode_bo(pt_bo, 0, pat_index, 0);
> +			if (vm)
> +				addr = vm->pt_ops->pte_encode_bo(pt_bo, 0, pat_index, 0);
> +			else
> +				addr = m->q->vm->pt_ops->pte_encode_bo(pt_bo, 0, pat_index, 0);
>   			bb->cs[bb->len++] = lower_32_bits(addr);
>   			bb->cs[bb->len++] = upper_32_bits(addr);
>   		}


More information about the Intel-xe mailing list