diff options
author | 2022-11-16 17:08:22 +0800 | |
---|---|---|
committer | 2022-11-23 10:31:25 -0500 | |
commit | 0317d73954850c48268f3db00a49e676d12b10cf (patch) | |
tree | 7319fb10484d555afd2cee548292aa2e30262eca /drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | |
parent | drm/amdgpu: update documentation of parameter amdgpu_gtt_size (diff) | |
download | linux-0317d73954850c48268f3db00a49e676d12b10cf.tar.gz linux-0317d73954850c48268f3db00a49e676d12b10cf.tar.bz2 linux-0317d73954850c48268f3db00a49e676d12b10cf.zip |
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 <Stanley.Yang@amd.com>
Reviewed-by: Tao Zhou <tao.zhou1@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_job.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c index 032651a655f0..7f1ca90a552c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c @@ -174,7 +174,12 @@ static void amdgpu_job_free_cb(struct drm_sched_job *s_job) drm_sched_job_cleanup(s_job); amdgpu_sync_free(&job->explicit_sync); - dma_fence_put(&job->hw_fence); + + /* only put the hw fence if has embedded fence */ + if (!job->hw_fence.ops) + kfree(job); + else + dma_fence_put(&job->hw_fence); } void amdgpu_job_set_gang_leader(struct amdgpu_job *job, |