On 1/1/2025 11:36 PM, Jiang Liu wrote:
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@xxxxxxxxxxxxxxxxx>
---
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;
Instead change drm/scheduler how about change amdgpu driver? At
amdgpu_device_init_schedulers if drm_sched_init fail for a ring
scheduler set
ring->sched->op = NULL;
It is not drm issue. If drm's scheduler init fail its operation has no
meaning, we can set it to null at amdgpu driver.
Regards
Xiaogang
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);