Skip to content

Commit 0317d73

Browse files
Stanley.Yangalexdeucher
authored andcommitted
drm/amdgpu: fix use-after-free during gpu recovery
[Why] [ 754.862560] refcount_t: underflow; use-after-free. [ 754.862898] Call Trace: [ 754.862903] <TASK> [ 754.862913] amdgpu_job_free_cb+0xc2/0xe1 [amdgpu] [ 754.863543] drm_sched_main.cold+0x34/0x39 [amd_sched] [How] The fw_fence may be not init, check whether dma_fence_init is performed before job free Signed-off-by: Stanley.Yang <[email protected]> Reviewed-by: Tao Zhou <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 2a59911 commit 0317d73

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_job.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,12 @@ static void amdgpu_job_free_cb(struct drm_sched_job *s_job)
174174
drm_sched_job_cleanup(s_job);
175175

176176
amdgpu_sync_free(&job->explicit_sync);
177-
dma_fence_put(&job->hw_fence);
177+
178+
/* only put the hw fence if has embedded fence */
179+
if (!job->hw_fence.ops)
180+
kfree(job);
181+
else
182+
dma_fence_put(&job->hw_fence);
178183
}
179184

180185
void amdgpu_job_set_gang_leader(struct amdgpu_job *job,

0 commit comments

Comments
 (0)