Hi,
The subject says 3/3 but I only see one patch submitted.
On 01/03/2026 18:24, Ali Khaledi wrote:
Fix several issues in the rocket accelerator driver:
rocket_gem.c: Add missing error check after
drm_mm_insert_node_generic(). The return value was silently
overwritten by iommu_map_sgtable(), causing DMA mapping to use
an uninitialized IOVA on MM insertion failure.
rocket_job.c: Add missing NULL check after kvmalloc_array() in
rocket_job_push(). A large job can trigger allocation failure,
leading to NULL pointer dereference in the following memcpy.
rocket_job.c: Add missing NULL check after kmalloc_objs() in
rocket_job_open(). Also fix memory leak of the scheds array
when drm_sched_entity_init() fails.
You could reduce the verbosity of this commit message - no need to show
filenames, and you can limit it just to pointing out what is not obvious
from the code change itself.
Found by AI-assisted code review (Claude Opus 4.6, Anthropic)
in collaboration with Ali Khaledi.
No need for this statement; if you understand the code and your proposed
changes, then submit it without crediting an agent. If you don't
understand it, then refrain from submitting until you personally can
stand behind your contribution.
Signed-off-by: Ali Khaledi <[email protected]>
---
drivers/accel/rocket/rocket_gem.c | 2 ++
drivers/accel/rocket/rocket_job.c | 9 ++++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/accel/rocket/rocket_gem.c
b/drivers/accel/rocket/rocket_gem.c
index b6a385d2e..7212edc3f 100644
--- a/drivers/accel/rocket/rocket_gem.c
+++ b/drivers/accel/rocket/rocket_gem.c
@@ -95,6 +95,8 @@ int rocket_ioctl_create_bo(struct drm_device *dev, void
*data, struct drm_file *
rkt_obj->size, PAGE_SIZE,
0, 0);
mutex_unlock(&rocket_priv->mm_lock);
+ if (ret)
+ goto err;
ret = iommu_map_sgtable(rocket_priv->domain->domain,
rkt_obj->mm.start,
diff --git a/drivers/accel/rocket/rocket_job.c
b/drivers/accel/rocket/rocket_job.c
index ac51bff39..6502b7148 100644
--- a/drivers/accel/rocket/rocket_job.c
+++ b/drivers/accel/rocket/rocket_job.c
@@ -192,6 +192,8 @@ 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 *));
These two have already been fixed in other commits.
@@ -501,6 +503,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;
@@ -508,8 +513,10 @@ int rocket_job_open(struct rocket_file_priv *rocket_priv)
DRM_SCHED_PRIORITY_NORMAL,
scheds,
rdev->num_cores, NULL);
- if (WARN_ON(ret))
+ if (WARN_ON(ret)) {
+ kfree(scheds);
return ret;
+ }
return 0;
}
This issue still stands but I would encourage you to do a deeper fix if
continuing your work here. Even in the non-error path if num_cores is 1
for any reason, it looks like drm will not set sched_list, so the memory
will be leaked there too. I think we need a better strategy for handling
the scheds.
Daniel