]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdkfd: add missing return value check for range
authorSunil Khatri <sunil.khatri@amd.com>
Fri, 24 Oct 2025 04:44:56 +0000 (10:14 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 28 Oct 2025 13:59:37 +0000 (09:59 -0400)
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 <sunil.khatri@amd.com>
Reviewed-by: Shirish S <shirish.s@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_svm.c

index f041643308ca49a7690d92ec5c48aff6cf9ccf2b..7f0ab73e23967f9a5ca1f1143756eb32dcd5bfd9 100644 (file)
@@ -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);