[PATCH 5/6] amdgpu: fix invalid memory access in amdgpu_fence_driver_sw_fini()
Jiang Liu
gerry at linux.alibaba.com
Thu Jan 2 05:36:56 UTC 2025
Function detects initialization status by checking sched->ops, so set
sched->ops to non-NULL just before return in function drm_sched_init()
to avoid possible invalid memory access on error recover path.
Signed-off-by: Jiang Liu <gerry at linux.alibaba.com>
---
drivers/gpu/drm/scheduler/sched_main.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index 5adab4b3386c..ce2afdfc0158 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -1331,6 +1331,8 @@ int drm_sched_init(struct drm_gpu_scheduler *sched,
if (sched->own_submit_wq)
destroy_workqueue(sched->submit_wq);
drm_err(sched, "%s: Failed to setup GPU scheduler--out of memory\n", __func__);
+ // amdgpu_fence_driver_sw_fini() checks sched->ops for status.
+ sched->ops = NULL;
return -ENOMEM;
}
EXPORT_SYMBOL(drm_sched_init);
@@ -1375,6 +1377,7 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched)
sched->ready = false;
kfree(sched->sched_rq);
sched->sched_rq = NULL;
+ sched->ops = NULL;
}
EXPORT_SYMBOL(drm_sched_fini);
--
2.43.5
More information about the amd-gfx
mailing list