[AMD Official Use Only - AMD Internal Distribution Only]

Reviewed-by: Shirish S <[email protected]>

Regards,
Shirish

-----Original Message-----
From: Khatri, Sunil <[email protected]>
Sent: Friday, October 24, 2025 5:15 PM
To: Khatri, Sunil <[email protected]>; Koenig, Christian 
<[email protected]>; Kuehling, Felix <[email protected]>; Deucher, 
Alexander <[email protected]>; Paneer Selvam, Arunpravin 
<[email protected]>; Yang, Philip <[email protected]>; 
[email protected]; S, Shirish <[email protected]>
Subject: Re: [Patch v2] drm/amdkfd: add missing return value check for range

+shirish

On 24-10-2025 04:46 pm, Sunil Khatri wrote:
> amdgpu_hmm_range_alloc could fails in case of low memory condition and
> hence we should have a check for the return value.
>
> Signed-off-by: Sunil Khatri <[email protected]>
> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> index f041643308ca..7f0ab73e2396 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> @@ -1738,6 +1738,11 @@ static int svm_range_validate_and_map(struct
> mm_struct *mm,
>
>                       WRITE_ONCE(p->svms.faulting_task, current);
>                       range = amdgpu_hmm_range_alloc(NULL);
> +                     if (unlikely(!range)) {
> +                             r = -ENOMEM;
> +                             goto free_ctx;
> +                     }
> +
>                       r = amdgpu_hmm_range_get_pages(&prange->notifier, addr, 
> npages,
>                                                      readonly, owner,
>                                                      range);

Reply via email to