drm/amdkfd: clean up the code to free hmm_range

a. hmm_range is either NULL or a valid pointer so we
do not need to set range to NULL ever.

b. keep the hmm_range_free in the end irrespective of
the other conditions to avoid some additional checks
and also avoid double free issue.

Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Sunil Khatri
2025-10-28 13:49:24 +05:30
committed by Alex Deucher
parent f67d54e96b
commit c0de552910

View File

@@ -1744,11 +1744,8 @@ static int svm_range_validate_and_map(struct mm_struct *mm,
else
r = -ENOMEM;
WRITE_ONCE(p->svms.faulting_task, NULL);
if (r) {
amdgpu_hmm_range_free(range);
range = NULL;
if (r)
pr_debug("failed %d to get svm range pages\n", r);
}
} else {
r = -EFAULT;
}
@@ -1771,10 +1768,9 @@ static int svm_range_validate_and_map(struct mm_struct *mm,
pr_debug("hmm update the range, need validate again\n");
r = -EAGAIN;
}
/* Free the hmm range */
if (range)
amdgpu_hmm_range_free(range);
/* Free the hmm range */
amdgpu_hmm_range_free(range);
if (!r && !list_empty(&prange->child_list)) {
pr_debug("range split by unmap in parallel, validate again\n");