From: Lizhi Hou <lizhi.hou@amd.com>
To: zishun yi <zishun.yi.dev@gmail.com>, Min Ma <mamin506@gmail.com>,
Oded Gabbay <ogabbay@kernel.org>
Cc: <dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] accel/amdxdna: Fix memory leak in amdxdna_ubuf_map
Date: Fri, 30 Jan 2026 13:09:50 -0800 [thread overview]
Message-ID: <1dd71e0f-50f5-ea30-e8f7-0f94ba90f361@amd.com> (raw)
In-Reply-To: <20260129171022.68578-1-zishun.yi.dev@gmail.com>
Applied to drm-misc-next-fixes.
On 1/29/26 09:10, zishun yi wrote:
> From: Zishun Yi <zishun.yi.dev@gmail.com>
>
> The amdxdna_ubuf_map() function allocates memory for sg and
> internal sg table structures, but it fails to free them if subsequent
> operations (sg_alloc_table_from_pages or dma_map_sgtable) fail.
>
> Fixes: bd72d4acda10 ("accel/amdxdna: Support user space allocated buffer")
> Signed-off-by: Zishun Yi <zishun.yi.dev@gmail.com>
> ---
> v2: Add 'Fixes' tag
>
> drivers/accel/amdxdna/amdxdna_ubuf.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/accel/amdxdna/amdxdna_ubuf.c b/drivers/accel/amdxdna/amdxdna_ubuf.c
> index 077b2261cf2a..9e3b3b055caa 100644
> --- a/drivers/accel/amdxdna/amdxdna_ubuf.c
> +++ b/drivers/accel/amdxdna/amdxdna_ubuf.c
> @@ -34,15 +34,21 @@ static struct sg_table *amdxdna_ubuf_map(struct dma_buf_attachment *attach,
> ret = sg_alloc_table_from_pages(sg, ubuf->pages, ubuf->nr_pages, 0,
> ubuf->nr_pages << PAGE_SHIFT, GFP_KERNEL);
> if (ret)
> - return ERR_PTR(ret);
> + goto err_free_sg;
>
> if (ubuf->flags & AMDXDNA_UBUF_FLAG_MAP_DMA) {
> ret = dma_map_sgtable(attach->dev, sg, direction, 0);
> if (ret)
> - return ERR_PTR(ret);
> + goto err_free_table;
> }
>
> return sg;
> +
> +err_free_table:
> + sg_free_table(sg);
> +err_free_sg:
> + kfree(sg);
> + return ERR_PTR(ret);
> }
>
> static void amdxdna_ubuf_unmap(struct dma_buf_attachment *attach,
prev parent reply other threads:[~2026-01-30 21:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-29 17:10 zishun yi
2026-01-29 17:23 ` Lizhi Hou
2026-01-30 7:35 ` Min Ma
2026-01-30 21:09 ` Lizhi Hou [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=1dd71e0f-50f5-ea30-e8f7-0f94ba90f361@amd.com \
--to=lizhi.hou@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mamin506@gmail.com \
--cc=ogabbay@kernel.org \
--cc=zishun.yi.dev@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®