Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu:fix memleak in takedown

this can fix the memory leak under the case that not all
BO are freed during "takedown" stage, because originally
it blocks following kfree on mgr.

Signed-off-by: Monk Liu <Monk.Liu@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Monk Liu and committed by
Alex Deucher
9ee8ecbb 451cc55d

-11
-6
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
··· 71 71 { 72 72 struct amdgpu_gtt_mgr *mgr = man->priv; 73 73 74 - spin_lock(&mgr->lock); 75 - if (!drm_mm_clean(&mgr->mm)) { 76 - spin_unlock(&mgr->lock); 77 - return -EBUSY; 78 - } 79 - 80 74 drm_mm_takedown(&mgr->mm); 81 75 spin_unlock(&mgr->lock); 82 76 kfree(mgr);
-5
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
··· 68 68 struct amdgpu_vram_mgr *mgr = man->priv; 69 69 70 70 spin_lock(&mgr->lock); 71 - if (!drm_mm_clean(&mgr->mm)) { 72 - spin_unlock(&mgr->lock); 73 - return -EBUSY; 74 - } 75 - 76 71 drm_mm_takedown(&mgr->mm); 77 72 spin_unlock(&mgr->lock); 78 73 kfree(mgr);