All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Shuvam Pandey" <shuvampandey1@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] accel/rocket: initialize job domain before cleanup paths
Date: Wed, 01 Jul 2026 17:31:55 +0000	[thread overview]
Message-ID: <20260701173156.1B3A11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <6a454b48.6a8fa39a.27019b.984b@mx.google.com>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:

Pre-existing issues:
- [Critical] Missing NULL check after `kvmalloc_array()` leads to an immediate kernel panic via `memcpy()`.
- [High] Calling `drm_sched_job_cleanup()` on an already-armed scheduler job violates the DRM scheduler API contract and leaks a sequence number.
- [High] Failure to attach the execution fence to input BOs causes a read-write data race.
- [High] Early error returns in `rocket_job_run()` leak PM runtime usage counters and return an unsignaled fence, hanging the DRM scheduler.
--

commit 6d28e47f76bcafb92f750ef15d6a214c957e5c54
Author: Shuvam Pandey <shuvampandey1@gmail.com>

accel/rocket: initialize job domain before cleanup paths
    
This patch moves the job domain initialization earlier in the job
submission process to prevent a NULL pointer dereference during error
cleanup. It also clears the task array pointer after freeing it to
avoid double-free issues.

> diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
> index 2f1861f960ccb..2b7222afc1975 100644
> --- a/drivers/accel/rocket/rocket_job.c
> +++ b/drivers/accel/rocket/rocket_job.c
[ ... ]
> @@ -573,8 +575,6 @@ static int rocket_ioctl_submit_job(struct drm_device *dev, struct drm_file *file
>  
>  	rjob->out_bo_count = job->out_bo_handle_count;
>  
> -	rjob->domain = rocket_iommu_domain_get(file_priv);
> -
>  	ret = rocket_job_push(rjob);

[Severity: Critical]
This is a pre-existing issue, but can this cause a kernel panic?

Looking at rocket_job_push(), if kvmalloc_array() fails and returns NULL,
would the subsequent memcpy() try to write to a NULL destination?

rocket_job_push():
    bos = kvmalloc_array(job->in_bo_count + job->out_bo_count, sizeof(void *),
                         GFP_KERNEL);
    memcpy(bos, job->in_bos, job->in_bo_count * sizeof(void *));


[Severity: High]
This isn't a bug introduced by this patch, but does this violate the DRM
scheduler API contract?

In rocket_job_push(), drm_sched_job_arm() is called before the fallible
rocket_acquire_object_fences(). If fence acquisition fails, does cleaning
up the already-armed job leave a gap in the fence timeline sequence?

rocket_job_push():
    drm_sched_job_arm(&job->base);
    ...
    ret = rocket_acquire_object_fences(job->in_bos, job->in_bo_count,
                                       &job->base, false);
    if (ret)
        goto err_unlock;


[Severity: High]
This is a pre-existing issue, but does this cause a read-write data race?

In rocket_job_push(), rocket_attach_object_fences() is only called for
out_bos. Should the inference_done_fence also be attached to in_bos as a
read dependency so subsequent jobs don't write to them while they are
still being read?

rocket_job_push():
    rocket_attach_object_fences(job->out_bos, job->out_bo_count,
                                job->inference_done_fence);


[Severity: High]
This isn't a bug introduced by this patch, but does this early return in
rocket_job_run() leak the PM runtime usage counter and hang the scheduler?

If pm_runtime_get_sync() fails, it still increments the runtime PM
counter. Does returning an unsignaled fence instead of an error pointer
cause the DRM scheduler to wait indefinitely?

rocket_job_run():
    ret = pm_runtime_get_sync(core->dev);
    if (ret < 0)
        return fence;

>  	if (ret)
>  		goto out_cleanup_job;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/6a454b48.6a8fa39a.27019b.984b@mx.google.com?part=1

      reply	other threads:[~2026-07-01 17:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01 17:15 [PATCH] accel/rocket: initialize job domain before cleanup paths Shuvam Pandey
2026-07-01 17:31 ` sashiko-bot [this message]

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=20260701173156.1B3A11F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shuvampandey1@gmail.com \
    /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.