From: sashiko-bot@kernel.org
To: "Deniz Aydogan" <denizaydogan1902@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] accel/amdxdna: fix NULL deref and GEM object leak in error paths
Date: Sat, 29 Aug 2026 08:23:34 +0000 [thread overview]
Message-ID: <20260829082334.93AEA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260829080016.10002-1-denizaydogan1902@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Incomplete fix for NULL pointer dereference of `job->cmd_bo` during internal driver command cleanup.
--
commit 85570ac4a3fda867670c08161dee7f7bfee5d853
Author: Deniz Aydogan <denizaydogan1902@gmail.com>
accel/amdxdna: fix NULL deref and GEM object leak in error paths
amdxdna_cmd_submit() does not set job->cmd_bo for internal driver
commands that pass AMDXDNA_INVALID_BO_HANDLE. If arg BO lookup fails
after that, the cmd_put cleanup calls amdxdna_gem_put_obj(NULL) which
dereferences a NULL pointer.
Separately, amdxdna_cmd_set_error() acquires a GEM reference via
amdxdna_gem_get_obj() when handling a chained command, but leaks it
when the subsequent amdxdna_gem_vmap() returns NULL.
Add a NULL check in the submit cleanup path and release the GEM
reference on vmap failure.
> diff --git a/drivers/accel/amdxdna/amdxdna_ctx.c b/drivers/accel/amdxdna/amdxdna_ctx.c
> index 31a414c3f0d96..c0444454afe6a 100644
> --- a/drivers/accel/amdxdna/amdxdna_ctx.c
> +++ b/drivers/accel/amdxdna/amdxdna_ctx.c
> @@ -676,7 +678,8 @@ int amdxdna_cmd_submit(struct amdxdna_client *client,
> put_bos:
> amdxdna_arg_bos_put(job);
> cmd_put:
> - amdxdna_gem_put_obj(job->cmd_bo);
> + if (job->cmd_bo)
> + amdxdna_gem_put_obj(job->cmd_bo);
[Severity: High]
This isn't a bug introduced by this patch, but does the same unconditional NULL
pointer dereference occur in the normal job completion cleanup path?
If userspace issues a configuration IOCTL (such as DRM_AMDXDNA_HWCTX_ASSIGN_DBG_BUF)
that submits an internal driver command, job->cmd_bo is deliberately left as
NULL during submission.
When the job completes, the DRM scheduler invokes aie2_sched_job_free() ->
aie2_job_release() -> amdxdna_sched_job_cleanup(), which unconditionally
calls amdxdna_gem_put_obj():
drivers/accel/amdxdna/amdxdna_ctx.c:amdxdna_sched_job_cleanup() {
...
amdxdna_pm_suspend_put(job->hwctx->client->xdna);
amdxdna_arg_bos_put(job);
amdxdna_gem_put_obj(job->cmd_bo);
dma_fence_put(job->fence);
...
}
Will this cause a kernel panic if job->cmd_bo is NULL?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260829080016.10002-1-denizaydogan1902@gmail.com?part=1
next prev parent reply other threads:[~2026-08-29 8:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-29 8:00 [PATCH] accel/amdxdna: fix NULL deref and GEM object leak in error paths Deniz Aydogan
2026-08-29 8:23 ` sashiko-bot [this message]
2026-08-29 8:56 ` [PATCH v2] " Deniz Aydogan
2026-08-31 20:38 ` Lizhi Hou
2026-09-02 11:49 ` [PATCH v2] accel/amdxdna: add NULL check for job->cmd_bo Deniz Aydogan
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=20260829082334.93AEA1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=denizaydogan1902@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.