Skip to contentSkip to conversation

drm/amdgpu: fix leak when we don't use the vm_fence

PATCH In review Alex Deucher 2 participants 2 messages Oct 22, 2025

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 drm/amdgpu: fix leak when we don't use the vm_fence

If we don't end up using the vm fence, we never initialize it so it never gets freed. Free it in that case.

Fixes db36632ea51e ("drm/amdgpu: clean up and unify hw fence handling")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -0
index db66b4232de02..f3373d5f429f8 100644
@@ -845,6 +845,9 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,
 		if (r)
 			return r;
 		fence = &job->hw_vm_fence->base;
+	} else {
+		/* free the vm fence if we are not using it */
+		kfree(job->hw_vm_fence);
 	}
 
 	if (vm_flush_needed) {
Signature · 1 line
2.51.0
#1 lore raw
Quoted 6 lines · Alex Deucher

If we don't end up using the vm fence, we never initialize it so it never gets freed. Free it in that case.

Fixes db36632ea51e ("drm/amdgpu: clean up and unify hw fence handling")

I have a better fix. Ignore this.

Alex

Quoted 21 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -1
index db66b4232de02..f3373d5f429f8 100644
@@ -845,6 +845,9 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,
                if (r)
                        return r;
                fence = &job->hw_vm_fence->base;
+       } else {
+               /* free the vm fence if we are not using it */
+               kfree(job->hw_vm_fence);
        }
 
        if (vm_flush_needed) {
--

2.51.0