* [PATCH] drm/lima: Drop the BO references if drm_sched_job_init() fails
@ 2026-11-24 4:39 Suyuan Wang via B4 Relay
0 siblings, 0 replies; only message in thread
From: Suyuan Wang via B4 Relay @ 2026-11-24 4:39 UTC (permalink / raw)
To: mripard, maarten.lankhorst, airlied, tzimmermann, simona, yuq825
Cc: linux-kernel, dri-devel, lima
From: Suyuan Wang <stevewong@hust.edu.cn>
lima_sched_task_init() takes a reference on every BO of the task before
it calls drm_sched_job_init():
for (i = 0; i < num_bos; i++)
drm_gem_object_get(&bos[i]->base.base);
err = drm_sched_job_init(&task->base, &context->base, 1, vm,
drm_client_id);
if (err) {
kfree(task->bos);
return err;
}
If drm_sched_job_init() fails (it can return -ENOMEM), only the array is
freed. lima_gem_submit() then goes to err_out1, which does not call
lima_sched_task_fini(), so these extra references are never dropped and
the BOs are not freed even after all other references are gone. This
can happen on every submit ioctl.
Put the references before freeing the array.
Found with a static analysis tool and checked by hand.
Fixes: a1d2a6339961 ("drm/lima: driver for ARM Mali4xx GPUs")
Cc: stable@vger.kernel.org
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
---
Compile tested on arm64 (W=1). I don't have the hardware.
---
drivers/gpu/drm/lima/lima_sched.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/lima/lima_sched.c b/drivers/gpu/drm/lima/lima_sched.c
index fee595b9629a..53d597850782 100644
--- a/drivers/gpu/drm/lima/lima_sched.c
+++ b/drivers/gpu/drm/lima/lima_sched.c
@@ -130,6 +130,8 @@ int lima_sched_task_init(struct lima_sched_task *task,
err = drm_sched_job_init(&task->base, &context->base, 1, vm,
drm_client_id);
if (err) {
+ for (i = 0; i < num_bos; i++)
+ drm_gem_object_put(&bos[i]->base.base);
kfree(task->bos);
return err;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-24 4:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24 4:39 [PATCH] drm/lima: Drop the BO references if drm_sched_job_init() fails Suyuan Wang via B4 Relay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®