Commit d2d3a440 authored by Ramesh Errabolu's avatar Ramesh Errabolu Committed by Alex Deucher

drm/amd/amdkfd: Fix a resource leak in svm_range_validate_and_map()

Analysis of code by Coverity, a static code analyser, has identified
a resource leak in the symbol hmm_range. This leak occurs when one of
the prior steps before it is released encounters an error.
Signed-off-by: default avatarRamesh Errabolu <Ramesh.Errabolu@amd.com>
Reviewed-by: default avatarFelix Kuehling <felix.kuehling@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 745e0a90
...@@ -1670,7 +1670,7 @@ static int svm_range_validate_and_map(struct mm_struct *mm, ...@@ -1670,7 +1670,7 @@ static int svm_range_validate_and_map(struct mm_struct *mm,
start = map_start << PAGE_SHIFT; start = map_start << PAGE_SHIFT;
end = (map_last + 1) << PAGE_SHIFT; end = (map_last + 1) << PAGE_SHIFT;
for (addr = start; !r && addr < end; ) { for (addr = start; !r && addr < end; ) {
struct hmm_range *hmm_range; struct hmm_range *hmm_range = NULL;
unsigned long map_start_vma; unsigned long map_start_vma;
unsigned long map_last_vma; unsigned long map_last_vma;
struct vm_area_struct *vma; struct vm_area_struct *vma;
...@@ -1705,7 +1705,12 @@ static int svm_range_validate_and_map(struct mm_struct *mm, ...@@ -1705,7 +1705,12 @@ static int svm_range_validate_and_map(struct mm_struct *mm,
} }
svm_range_lock(prange); svm_range_lock(prange);
if (!r && amdgpu_hmm_range_get_pages_done(hmm_range)) {
/* Free backing memory of hmm_range if it was initialized
* Overrride return value to TRY AGAIN only if prior returns
* were successful
*/
if (hmm_range && amdgpu_hmm_range_get_pages_done(hmm_range) && !r) {
pr_debug("hmm update the range, need validate again\n"); pr_debug("hmm update the range, need validate again\n");
r = -EAGAIN; r = -EAGAIN;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment