drm/amdgpu:fix memleak in takedown
authorMonk Liu <Monk.Liu@amd.com>
Tue, 14 Nov 2017 08:48:06 +0000 (16:48 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 16 Nov 2017 18:35:48 +0000 (13:35 -0500)
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>
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c

index 33535d3477343bab044dba5c1cb171ed6befa475..00e0ce10862f7275655710c2559b2286dacb136b 100644 (file)
@@ -71,12 +71,6 @@ static int amdgpu_gtt_mgr_fini(struct ttm_mem_type_manager *man)
 {
        struct amdgpu_gtt_mgr *mgr = man->priv;
 
-       spin_lock(&mgr->lock);
-       if (!drm_mm_clean(&mgr->mm)) {
-               spin_unlock(&mgr->lock);
-               return -EBUSY;
-       }
-
        drm_mm_takedown(&mgr->mm);
        spin_unlock(&mgr->lock);
        kfree(mgr);
index 26e90062797173d772b4c71c2f3229ebb1bfbbbc..4acca92f6a52da27b460cfb28bef9a05c571acfa 100644 (file)
@@ -68,11 +68,6 @@ static int amdgpu_vram_mgr_fini(struct ttm_mem_type_manager *man)
        struct amdgpu_vram_mgr *mgr = man->priv;
 
        spin_lock(&mgr->lock);
-       if (!drm_mm_clean(&mgr->mm)) {
-               spin_unlock(&mgr->lock);
-               return -EBUSY;
-       }
-
        drm_mm_takedown(&mgr->mm);
        spin_unlock(&mgr->lock);
        kfree(mgr);