From: Triet Hoang <triet.hoang.dev@gmail.com>
To: sidong.yang@furiosa.ai, royalnet026@gmail.com
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
ogabbay@kernel.org, tomeu@tomeuvizoso.net,
triet.hoang.dev@gmail.com
Subject: [PATCH v6 2/2] drm/rocket: Keep scheduler allocation in rocket_file_priv
Date: Mon, 14 Sep 2026 11:56:05 +0700 [thread overview]
Message-ID: <20260914045605.381933-3-triet.hoang.dev@gmail.com> (raw)
In-Reply-To: <20260914045605.381933-1-triet.hoang.dev@gmail.com>
The scheduler array passed to drm_sched_entity_init() is retained by the
entity when the device has multiple cores. drm_sched_entity_init() stores
the list conditionally:
entity->sched_list = num_sched_list > 1 ? sched_list : NULL;
With one scheduler, it keeps only entity->rq and drops the array pointer
while rocket_job_open() allows its local copy to go out of scope. So
for num_cores == 1 the kfree() in rocket_job_close() is a kfree(NULL)
and the array leaks unreachably. For num_cores > 1 there is no leak,
which is why this is invisible in normal use on RK3588.
Keep the allocation in rocket_file_priv so rocket_job_close() can destroy
the entity before freeing the array. Free the array directly if entity
initialization fails, since rocket_job_open() does not call
rocket_job_close() on that error path.
Fixes: 0810d5ad88a1 ("accel/rocket: Add job submission IOCTL")
Suggested-by: Igor Paunovic <royalnet026@gmail.com>
Link: https://lore.kernel.org/all/20260817093009.22359-1-royalnet026@gmail.com/
Signed-off-by: Triet Hoang <triet.hoang.dev@gmail.com>
Tested-by: Igor Paunovic <royalnet026@gmail.com>
Tested-by: Sidong Yang <sidong.yang@furiosa.ai>
---
Changes in v5:
- Free rocket_priv->scheds instead of entity->sched_list in rocket_job_close().
Changes in v6:
- Add Tested-by and Fixes tags.
- Move kfree() below the drm_sched_entity_destroy() call in rocket_job_close().
- Update commit message to explain why the scheduler array must outlive the scheduler entity.
---
drivers/accel/rocket/rocket_drv.h | 1 +
drivers/accel/rocket/rocket_job.c | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/accel/rocket/rocket_drv.h b/drivers/accel/rocket/rocket_drv.h
index 2c673bb99ccc..9421e48ec5d8 100644
--- a/drivers/accel/rocket/rocket_drv.h
+++ b/drivers/accel/rocket/rocket_drv.h
@@ -23,6 +23,7 @@ struct rocket_file_priv {
struct drm_mm mm;
struct mutex mm_lock;
+ struct drm_gpu_scheduler **scheds;
struct drm_sched_entity sched_entity;
};
diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
index 704a15513179..f27e6264f91d 100644
--- a/drivers/accel/rocket/rocket_job.c
+++ b/drivers/accel/rocket/rocket_job.c
@@ -528,6 +528,8 @@ int rocket_job_open(struct rocket_file_priv *rocket_priv)
rdev->num_cores, NULL);
if (ret)
kfree(scheds);
+ else
+ rocket_priv->scheds = scheds;
return ret;
}
@@ -536,8 +538,8 @@ void rocket_job_close(struct rocket_file_priv *rocket_priv)
{
struct drm_sched_entity *entity = &rocket_priv->sched_entity;
- kfree(entity->sched_list);
drm_sched_entity_destroy(entity);
+ kfree(rocket_priv->scheds);
}
int rocket_job_is_idle(struct rocket_core *core)
--
2.53.0
next prev parent reply other threads:[~2026-09-14 4:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 4:56 [PATCH v6 0/2] accel/rocket: Fix allocation handling and scheduler array leak Triet Hoang
2026-09-14 4:56 ` [PATCH v6 1/2] accel/rocket: Check allocations before use Triet Hoang
2026-09-14 5:08 ` sashiko-bot
2026-09-14 13:34 ` Igor Paunovic
2026-09-14 4:56 ` Triet Hoang [this message]
2026-09-14 5:09 ` [PATCH v6 2/2] drm/rocket: Keep scheduler allocation in rocket_file_priv sashiko-bot
2026-09-14 13:30 ` Igor Paunovic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260914045605.381933-3-triet.hoang.dev@gmail.com \
--to=triet.hoang.dev@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ogabbay@kernel.org \
--cc=royalnet026@gmail.com \
--cc=sidong.yang@furiosa.ai \
--cc=tomeu@tomeuvizoso.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.