Commit 0dc204bc authored by Lang Yu's avatar Lang Yu Committed by Alex Deucher

drm/amdkfd: fix kgd_mem memory leak when importing dmabuf

The kgd_mem memory allocated in amdgpu_amdkfd_gpuvm_import_dmabuf()
is not freed properly.

Explicitly free it in amdgpu_amdkfd_gpuvm_free_memory_of_gpu()
under condition "mem->bo->kfd_bo != mem".
Suggested-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarLang Yu <Lang.Yu@amd.com>
Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 3d2af401
...@@ -1775,6 +1775,7 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu( ...@@ -1775,6 +1775,7 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
{ {
struct amdkfd_process_info *process_info = mem->process_info; struct amdkfd_process_info *process_info = mem->process_info;
unsigned long bo_size = mem->bo->tbo.base.size; unsigned long bo_size = mem->bo->tbo.base.size;
bool use_release_notifier = (mem->bo->kfd_bo == mem);
struct kfd_mem_attachment *entry, *tmp; struct kfd_mem_attachment *entry, *tmp;
struct bo_vm_reservation_context ctx; struct bo_vm_reservation_context ctx;
struct ttm_validate_buffer *bo_list_entry; struct ttm_validate_buffer *bo_list_entry;
...@@ -1866,6 +1867,13 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu( ...@@ -1866,6 +1867,13 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
*/ */
drm_gem_object_put(&mem->bo->tbo.base); drm_gem_object_put(&mem->bo->tbo.base);
/*
* For kgd_mem allocated in amdgpu_amdkfd_gpuvm_import_dmabuf(),
* explicitly free it here.
*/
if (!use_release_notifier)
kfree(mem);
return ret; return ret;
} }
......
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