From: Lizhi Hou <lizhi.hou@amd.com>
To: Eva Crystal <0xiviel@gmail.com>, Min Ma <mamin506@gmail.com>
Cc: <dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/4] accel/amdxdna: release the chained command BO when vmap fails
Date: Mon, 14 Sep 2026 10:37:51 -0700 [thread overview]
Message-ID: <02d63343-acaa-38fd-e007-33256bb5f409@amd.com> (raw)
In-Reply-To: <20260912081012.2274075-4-0xiviel@gmail.com>
On 9/12/26 01:10, Eva Crystal wrote:
> When amdxdna_cmd_set_error() follows a command chain it takes a
> reference on the BO named by the chain:
>
> abo = amdxdna_gem_get_obj(client, cc->data[0], AMDXDNA_BO_SHARE);
> if (!abo)
> return -EINVAL;
> cmd = amdxdna_gem_vmap(abo);
> if (!cmd)
> return -ENOMEM;
>
> and drops it at the end of the function under "if (cc)". The -ENOMEM
> path returns before reaching that, so the reference taken by
> amdxdna_gem_get_obj() is leaked and the GEM object is never freed.
>
> amdxdna_gem_vmap() fails only if drm_gem_vmap() fails, which needs
> memory pressure or an exporter that refuses the mapping, so this is a
> small leak on a rare path rather than something a caller can drive at
> will. It is still a leak, and the chain BO handle comes from a command
> buffer user space can write.
>
> Drop the reference before returning.
>
> Signed-off-by: Eva Crystal <0xiviel@gmail.com>
> ---
> drivers/accel/amdxdna/amdxdna_ctx.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/accel/amdxdna/amdxdna_ctx.c b/drivers/accel/amdxdna/amdxdna_ctx.c
> index c24bf1c..7a61e83 100644
> --- a/drivers/accel/amdxdna/amdxdna_ctx.c
> +++ b/drivers/accel/amdxdna/amdxdna_ctx.c
> @@ -170,8 +170,10 @@ int amdxdna_cmd_set_error(struct amdxdna_gem_obj *abo,
> if (!abo)
> return -EINVAL;
> cmd = amdxdna_gem_vmap(abo);
> - if (!cmd)
> + if (!cmd) {
> + amdxdna_gem_put_obj(abo);
> return -ENOMEM;
> + }
Thanks for providing the patch. This has been fixed by:
https://lore.kernel.org/all/20260819230852.287751-1-taimuraz@kaitmazov.com/
Lizhi
> }
>
> if (abo->mem.size < sizeof(*cmd)) {
next prev parent reply other threads:[~2026-09-14 17:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-12 8:10 [PATCH 0/4] accel/amdxdna: harden command BO payload validation Eva Crystal
2026-09-12 8:10 ` [PATCH 1/4] accel/amdxdna: validate the command payload regardless of the size argument Eva Crystal
2026-09-12 8:10 ` [PATCH 2/4] accel/amdxdna: bound the command error payload length Eva Crystal
2026-09-12 8:10 ` [PATCH 3/4] accel/amdxdna: release the chained command BO when vmap fails Eva Crystal
2026-09-14 17:37 ` Lizhi Hou [this message]
2026-09-12 8:10 ` [PATCH 4/4] accel/amdxdna: check the command payload before using it in the exec requests Eva Crystal
2026-09-14 18:25 ` [PATCH 0/4] accel/amdxdna: harden command BO payload validation Lizhi Hou
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=02d63343-acaa-38fd-e007-33256bb5f409@amd.com \
--to=lizhi.hou@amd.com \
--cc=0xiviel@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mamin506@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 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®