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); -- 2.34.1
