Skip to contentSkip to conversation

drm/amdgpu: fix memleak of ring sched and fence driver

PATCH In review Lin.Cao 2 participants 2 messages Sep 5, 2025

Subsystems (2)
lore
Share & tools
lore

Lin.Cao

author
#0 lore raw

PATCH v2 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.

Remove set rings[ring->idx] as NULL to fix this issue

Fixes 4220d2c7c41b ("drm/amdgpu: remove is_mes_queue flag")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0 -2
index 6379bb25bf5c..486c3646710c 100644
@@ -421,8 +421,6 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring)
 	dma_fence_put(ring->vmid_wait);
 	ring->vmid_wait = NULL;
 	ring->me = 0;
-
-	ring->adev->rings[ring->idx] = NULL;
 }
 
 /**
Signature · 1 line
2.50.1
maintainer
#1 lore raw

Alex already send exactly that patch yesterday.

Please review that one instead.

Thanks,
Christian.

Quoted 26 lines · Lin.Cao

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.

Remove set rings[ring->idx] as NULL to fix this issue

Fixes 4220d2c7c41b ("drm/amdgpu: remove is_mes_queue flag")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0 -2
index 6379bb25bf5c..486c3646710c 100644
@@ -421,8 +421,6 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring)
 	dma_fence_put(ring->vmid_wait);
 	ring->vmid_wait = NULL;
 	ring->me = 0;
-
-	ring->adev->rings[ring->idx] = NULL;
 }
 
 /**