Skip to contentSkip to conversation

drm/amdgpu: fix possible fence leaks from job structure

PATCH In review Alex Deucher 3 participants 3 messages Oct 22, 2025 – Oct 24, 2025

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 drm/amdgpu: fix possible fence leaks from job structure

If we don't end up initializing the fences, free then when we free the job.

Fixes db36632ea51e ("drm/amdgpu: clean up and unify hw fence handling")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +10 -0
index 3d396ab625f33..8ad8b16e96760 100644
@@ -295,6 +295,11 @@ static void amdgpu_job_free_cb(struct drm_sched_job *s_job)
 
 	amdgpu_sync_free(&job->explicit_sync);
 
+	if (!job->hw_fence->base.ops)
+		kfree(job->hw_fence);
+	if (!job->hw_vm_fence->base.ops)
+		kfree(job->hw_vm_fence);
+
 	kfree(job);
 }
 
@@ -324,6 +329,11 @@ void amdgpu_job_free(struct amdgpu_job *job)
 	if (job->gang_submit != &job->base.s_fence->scheduled)
 		dma_fence_put(job->gang_submit);
 
+	if (!job->hw_fence->base.ops)
+		kfree(job->hw_fence);
+	if (!job->hw_vm_fence->base.ops)
+		kfree(job->hw_vm_fence);
+
 	kfree(job);
 }
 
Signature · 1 line
2.51.0
#1 lore raw

Ping?

Alex

Quoted 41 lines · Alex Deucher

If we don't end up initializing the fences, free then when we free the job.

Fixes db36632ea51e ("drm/amdgpu: clean up and unify hw fence handling")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +10 -1
index 3d396ab625f33..8ad8b16e96760 100644
@@ -295,6 +295,11 @@ static void amdgpu_job_free_cb(struct drm_sched_job *s_job)
 
        amdgpu_sync_free(&job->explicit_sync);
 
+       if (!job->hw_fence->base.ops)
+               kfree(job->hw_fence);
+       if (!job->hw_vm_fence->base.ops)
+               kfree(job->hw_vm_fence);
+
        kfree(job);
 }
 
@@ -324,6 +329,11 @@ void amdgpu_job_free(struct amdgpu_job *job)
        if (job->gang_submit != &job->base.s_fence->scheduled)
                dma_fence_put(job->gang_submit);
 
+       if (!job->hw_fence->base.ops)
+               kfree(job->hw_fence);
+       if (!job->hw_vm_fence->base.ops)
+               kfree(job->hw_vm_fence);
+
        kfree(job);
 }
 
--

2.51.0

#2 lore raw
In reply to Alex Deucher

[AMD Official Use Only - AMD Internal Distribution Only]

this patch is Reviewed-by: Jesse Zhang <[email protected]>

Quoted 48 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, October 23, 2025 5:20 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH] drm/amdgpu: fix possible fence leaks from job structure

If we don't end up initializing the fences, free then when we free the job.

Fixes db36632ea51e ("drm/amdgpu: clean up and unify hw fence handling")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +10 -1
index 3d396ab625f33..8ad8b16e96760 100644
@@ -295,6 +295,11 @@ static void amdgpu_job_free_cb(struct drm_sched_job
 *s_job)
 
      amdgpu_sync_free(&job->explicit_sync);
 
+     if (!job->hw_fence->base.ops)
+             kfree(job->hw_fence);
+     if (!job->hw_vm_fence->base.ops)
+             kfree(job->hw_vm_fence);
+
      kfree(job);
 }
@@ -324,6 +329,11 @@ void amdgpu_job_free(struct amdgpu_job *job)
      if (job->gang_submit != &job->base.s_fence->scheduled)
              dma_fence_put(job->gang_submit);
 
+     if (!job->hw_fence->base.ops)
+             kfree(job->hw_fence);
+     if (!job->hw_vm_fence->base.ops)
+             kfree(job->hw_vm_fence);
+
      kfree(job);
 }
 
--

2.51.0