* [PATCH] drm/rocket: Check allocations before use
@ 2026-08-17 5:39 Triet Hoang
0 siblings, 0 replies; 2+ messages in thread
From: Triet Hoang @ 2026-08-17 5:39 UTC (permalink / raw)
To: tomeu; +Cc: ogabbay, dri-devel, linux-kernel, Triet Hoang
Check the result of kvmalloc_array() in rocket_job_push() and
kmalloc_objs() in rocket_job_open() before using
the allocated buffer.
Signed-off-by: Triet Hoang <triet.hoang.dev@gmail.com>
---
drivers/accel/rocket/rocket_job.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
index ac51bff39833..2fee21988d27 100644
--- a/drivers/accel/rocket/rocket_job.c
+++ b/drivers/accel/rocket/rocket_job.c
@@ -192,6 +192,9 @@ static int rocket_job_push(struct rocket_job *job)
bos = kvmalloc_array(job->in_bo_count + job->out_bo_count, sizeof(void *),
GFP_KERNEL);
+ if (!bos)
+ return -ENOMEM;
+
memcpy(bos, job->in_bos, job->in_bo_count * sizeof(void *));
memcpy(&bos[job->in_bo_count], job->out_bos, job->out_bo_count * sizeof(void *));
@@ -501,6 +504,9 @@ int rocket_job_open(struct rocket_file_priv *rocket_priv)
unsigned int core;
int ret;
+ if (!scheds)
+ return -ENOMEM;
+
for (core = 0; core < rdev->num_cores; core++)
scheds[core] = &rdev->cores[core].sched;
--
2.53.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [v4 1/2] drm/rocket: Check allocations before use
@ 2026-08-18 5:48 Markus Elfring
2026-08-18 6:21 ` [PATCH] " Triet Hoang
0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2026-08-18 5:48 UTC (permalink / raw)
To: Triet Hoang, dri-devel
Cc: kernel-janitors, linux-kernel, Igor Paunovic, Oded Gabbay, Tomeu Vizoso
>> I see opportunities for corresponding collateral evolution.
>> How do you think about to apply the attribute “__free(kvfree)” also in such
>> a function implementation by another update step?
>
> I am not sure I understand your idea.
> Could you explain more? This attribute is a new thing to media
There are programming interfaces supported to some degree
for the application of scope-based resource management.
https://elixir.bootlin.com/linux/v7.2-rc7/source/include/linux/cleanup.h#L10
Would you like to take any adjustment possibilities better into account accordingly?
Regards,
Markus
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/rocket: Check allocations before use
2026-08-18 5:48 [v4 1/2] " Markus Elfring
@ 2026-08-18 6:21 ` Triet Hoang
0 siblings, 0 replies; 2+ messages in thread
From: Triet Hoang @ 2026-08-18 6:21 UTC (permalink / raw)
To: markus.elfring
Cc: dri-devel, kernel-janitors, linux-kernel, ogabbay, royalnet026,
tomeu, triet.hoang.dev
> > There are programming interfaces supported to some degree
> for the application of scope-based resource management.
> https://elixir.bootlin.com/linux/v7.2-rc7/source/include/linux/cleanup.h#L10
>
> Would you like to take any adjustment possibilities better into account accordingly?
Thanks for explaining. I am happy to continue working on this, but I think
this would be more of a refactoring to use the new API than a bug fix.
Furthermore, I don't have much experience with the new cleanup API yet, so
I think it would be better to consider this as a separate change in the
future, after these patches have been reviewed and I have gained more
experience with the new API.
Anyway, thanks for suggesting this. I'll take a look at it and keep it in
mind for future changes.
Regards,
Triet
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-18 6:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-17 5:39 [PATCH] drm/rocket: Check allocations before use Triet Hoang
2026-08-18 5:48 [v4 1/2] " Markus Elfring
2026-08-18 6:21 ` [PATCH] " Triet Hoang
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®