From: Ruoyu Wang <ruoyuw560@gmail.com>
To: ogabbay@kernel.org, quic_jhugo@quicinc.com, joro@8bytes.org
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
amd-gfx@lists.freedesktop.org, Ruoyu Wang <ruoyuw560@gmail.com>
Subject: [PATCH] accel/amdxdna: Clear mailbox channel after create failure
Date: Thu, 9 Jul 2026 14:22:56 +0800 [thread overview]
Message-ID: <20260709062256.4166833-1-ruoyuw560@gmail.com> (raw)
aie2_create_context() stores the allocated mailbox channel in
hwctx->priv->mbox_chann before starting the channel. If
xdna_mailbox_start_channel() fails, the error path frees the channel but
leaves the saved pointer intact.
A later context cleanup only checks whether hwctx->priv->mbox_chann is
NULL before stopping and freeing it. Leaving the freed channel pointer
there can therefore make cleanup operate on stale memory.
Clear hwctx->priv->mbox_chann after freeing the channel on the create
failure path so later cleanup sees that no mailbox channel is owned.
A static analysis checker reported the stale ownership state, and manual
source review confirmed the error path.
Fixes: d5b8b0347fa8 ("accel/amdxdna: Split mailbox channel create function")
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
drivers/accel/amdxdna/aie2_message.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/accel/amdxdna/aie2_message.c b/drivers/accel/amdxdna/aie2_message.c
index c4b364801cc04..a22d025794598 100644
--- a/drivers/accel/amdxdna/aie2_message.c
+++ b/drivers/accel/amdxdna/aie2_message.c
@@ -277,6 +277,7 @@ int aie2_create_context(struct amdxdna_dev_hdl *ndev, struct amdxdna_hwctx *hwct
free_channel:
xdna_mailbox_free_channel(hwctx->priv->mbox_chann);
+ hwctx->priv->mbox_chann = NULL;
del_ctx_req:
aie2_destroy_context_req(ndev, hwctx->fw_ctx_id);
return ret;
--
2.51.0
reply other threads:[~2026-07-09 6:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260709062256.4166833-1-ruoyuw560@gmail.com \
--to=ruoyuw560@gmail.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ogabbay@kernel.org \
--cc=quic_jhugo@quicinc.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 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®