From: Lizhi Hou <lizhi.hou@amd.com>
To: Mario Limonciello <superm1@kernel.org>, <ogabbay@kernel.org>,
<quic_jhugo@quicinc.com>, <dri-devel@lists.freedesktop.org>,
<maciej.falkowski@linux.intel.com>
Cc: Max Zhen <max.zhen@amd.com>, <linux-kernel@vger.kernel.org>,
<sonal.santan@amd.com>
Subject: Re: [PATCH V1] accel/amdxdna: Fix leak when pinning ubuf pages
Date: Thu, 26 Mar 2026 09:11:40 -0700 [thread overview]
Message-ID: <6b0c8417-91a2-01d6-1298-18800a40b581@amd.com> (raw)
In-Reply-To: <b1333a9f-1034-4e3d-a1bd-b6e1348a9f87@kernel.org>
Applied to drm-misc-next
On 3/25/26 19:31, Mario Limonciello wrote:
>
>
> On 3/25/26 20:06, Lizhi Hou wrote:
>> From: Max Zhen <max.zhen@amd.com>
>>
>> When pin_user_pages_fast() returns fewer pages than requested, the pages
>> that were successfully pinned are not released, leading to a leak.
>>
>> Fix this by unpinning any partially pinned pages before returning
>> failure.
>>
>> Fixes: bd72d4acda10 ("accel/amdxdna: Support user space allocated
>> buffer")
>> Signed-off-by: Max Zhen <max.zhen@amd.com>
>> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
> Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
>> ---
>> drivers/accel/amdxdna/amdxdna_ubuf.c | 12 ++++++++----
>> 1 file changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/accel/amdxdna/amdxdna_ubuf.c
>> b/drivers/accel/amdxdna/amdxdna_ubuf.c
>> index fb999aa25318..4c0647057759 100644
>> --- a/drivers/accel/amdxdna/amdxdna_ubuf.c
>> +++ b/drivers/accel/amdxdna/amdxdna_ubuf.c
>> @@ -196,13 +196,17 @@ struct dma_buf *amdxdna_get_ubuf(struct
>> drm_device *dev,
>> ret = pin_user_pages_fast(va_ent[i].vaddr, npages,
>> FOLL_WRITE | FOLL_LONGTERM,
>> &ubuf->pages[start]);
>> - if (ret < 0 || ret != npages) {
>> - ret = -ENOMEM;
>> + if (ret >= 0) {
>> + start += ret;
>> + if (ret != npages) {
>> + XDNA_ERR(xdna, "Partially pinned pages %d/%u", ret,
>> npages);
>> + ret = -ENOMEM;
>> + goto destroy_pages;
>> + }
>> + } else {
>> XDNA_ERR(xdna, "Failed to pin pages ret %d", ret);
>> goto destroy_pages;
>> }
>> -
>> - start += ret;
>> }
>> exp_info.ops = &amdxdna_ubuf_dmabuf_ops;
>
prev parent reply other threads:[~2026-03-26 16:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-26 1:06 Lizhi Hou
2026-03-26 2:31 ` Mario Limonciello
2026-03-26 16:11 ` 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=6b0c8417-91a2-01d6-1298-18800a40b581@amd.com \
--to=lizhi.hou@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maciej.falkowski@linux.intel.com \
--cc=max.zhen@amd.com \
--cc=ogabbay@kernel.org \
--cc=quic_jhugo@quicinc.com \
--cc=sonal.santan@amd.com \
--cc=superm1@kernel.org \
/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®