Commit a872c152 authored by Philip Yang's avatar Philip Yang Committed by Alex Deucher

drm/amdkfd: fix double free mem structure

drm_gem_object_put calls release_notify callback to free the mem
structure and unreserve_mem_limit, move it down after the last access
of mem and make it conditional call.
Signed-off-by: default avatarPhilip Yang <Philip.Yang@amd.com>
Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 71f8f119
...@@ -1460,7 +1460,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( ...@@ -1460,7 +1460,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
struct sg_table *sg = NULL; struct sg_table *sg = NULL;
uint64_t user_addr = 0; uint64_t user_addr = 0;
struct amdgpu_bo *bo; struct amdgpu_bo *bo;
struct drm_gem_object *gobj; struct drm_gem_object *gobj = NULL;
u32 domain, alloc_domain; u32 domain, alloc_domain;
u64 alloc_flags; u64 alloc_flags;
int ret; int ret;
...@@ -1582,14 +1582,16 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( ...@@ -1582,14 +1582,16 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
err_pin_bo: err_pin_bo:
drm_vma_node_revoke(&gobj->vma_node, drm_priv); drm_vma_node_revoke(&gobj->vma_node, drm_priv);
err_node_allow: err_node_allow:
drm_gem_object_put(gobj);
/* Don't unreserve system mem limit twice */ /* Don't unreserve system mem limit twice */
goto err_reserve_limit; goto err_reserve_limit;
err_bo_create: err_bo_create:
unreserve_mem_limit(adev, size, flags); unreserve_mem_limit(adev, size, flags);
err_reserve_limit: err_reserve_limit:
mutex_destroy(&(*mem)->lock); mutex_destroy(&(*mem)->lock);
kfree(*mem); if (gobj)
drm_gem_object_put(gobj);
else
kfree(*mem);
err: err:
if (sg) { if (sg) {
sg_free_table(sg); sg_free_table(sg);
......
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