drm/scheduler: always put last_sched fence in entity_fini
authorPixel Ding <Pixel.Ding@amd.com>
Wed, 18 Apr 2018 08:33:26 +0000 (04:33 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 15 May 2018 18:43:30 +0000 (13:43 -0500)
Fix the potential memleak since scheduler main thread always
hold one last_sched fence.

Signed-off-by: Pixel Ding <Pixel.Ding@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/scheduler/gpu_scheduler.c

index 44d21981bf3bc123e133de4e91883ca32fe37558..4968867da7a632fac695db49de7a3d08bfec9869 100644 (file)
@@ -276,10 +276,10 @@ void drm_sched_entity_cleanup(struct drm_gpu_scheduler *sched,
                        else if (r)
                                DRM_ERROR("fence add callback failed (%d)\n", r);
                }
-
-               dma_fence_put(entity->last_scheduled);
-               entity->last_scheduled = NULL;
        }
+
+       dma_fence_put(entity->last_scheduled);
+       entity->last_scheduled = NULL;
 }
 EXPORT_SYMBOL(drm_sched_entity_cleanup);