Commit c0de5529 authored by Sunil Khatri's avatar Sunil Khatri Committed by Alex Deucher
Browse files

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: default avatarSunil Khatri <sunil.khatri@amd.com>
Reviewed-by: default avatarFelix Kuehling <felix.kuehling@amd.com>
Acked-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent f67d54e9
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -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,11 +1768,10 @@ 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);


		if (!r && !list_empty(&prange->child_list)) {
			pr_debug("range split by unmap in parallel, validate again\n");
			r = -EAGAIN;