drm/amdgpu: fix memleak of ring sched and fence driver
Subsystems (2)
PATCH 1/1 drm/amdgpu: fix memleak of ring sched and fence driver
commit 4220d2c7c41b ("drm/amdgpu: remove is_mes_queue flag") set ring->adev->ring[ring-idx] as NULL at the end of function amdgpu_ring_fini() which will cause function amdgpu_fence_driver_sw_fini() skip drm_sched_fini() and free fence_drv.fence then cause memory leak.
Release these resource at the beginning of amdgpu_ring_fini() to fix this issue.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +13 -0
@@ -406,6 +406,19 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring) ring->sched.ready = false; +if (ring->fence_drv.initialized) { +int i =0 ; + +if (ring->sched.ops) +drm_sched_fini (&ring->sched); + +for (i =0 ; i <= ring->fence_drv.num_fences_mask; ++i) +dma_fence_put (ring->fence_drv.fences[i]); +kfree (ring->fence_drv.fences); + ring->fence_drv.fences =NULL ; + ring->fence_drv.initialized = false; + } +amdgpu_device_wb_free (ring->adev, ring->rptr_offs);amdgpu_device_wb_free (ring->adev, ring->wptr_offs);
Signature · 1 line
2.46.1
Christian König
maintainerQuoted 2 lines · Lin.Cao
commit
4220d2c7c41b("drm/amdgpu: removeis_mes_queueflag") set ring->adev->ring[ring-idx] as NULL at the end of functionamdgpu_ring_fini()
That is a bug and should probably be fixed instead of this here.
Regards,
Christian.
Quoted 36 lines
which will cause function
amdgpu_fence_driver_sw_fini()skipdrm_sched_fini()and free fence_drv.fence then cause memory leak.Release these resource at the beginning of
amdgpu_ring_fini()to fix this issue.Fixes 4220d2c7c41b ("drm/amdgpu: remove is_mes_queue flag")Signed-off-by Lin.Cao <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +13
-0@@ -406,6 +406,19 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring) ring->sched.ready = false; +if (ring->fence_drv.initialized) { +int i =0 ; + +if (ring->sched.ops) +drm_sched_fini (&ring->sched); + +for (i =0 ; i <= ring->fence_drv.num_fences_mask; ++i) +dma_fence_put (ring->fence_drv.fences[i]); +kfree (ring->fence_drv.fences); + ring->fence_drv.fences =NULL ; + ring->fence_drv.initialized = false; + } +amdgpu_device_wb_free (ring->adev, ring->rptr_offs);amdgpu_device_wb_free (ring->adev, ring->wptr_offs);