public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tursulin@ursulin.net>
To: Alex Deucher <alexdeucher@gmail.com>
Cc: "Thorsten Blum" <thorsten.blum@linux.dev>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/amdgpu: Replace kzalloc + copy_from_user with memdup_user
Date: Wed, 10 Sep 2025 11:09:21 +0100	[thread overview]
Message-ID: <d51e11fa-54b0-41f4-9b06-95b46094de39@ursulin.net> (raw)
In-Reply-To: <CADnq5_NDrq_S7rcpr6_MY-USfVGr8-QcJ2hqnai7VEm5D_OyxQ@mail.gmail.com>


On 09/09/2025 14:36, Alex Deucher wrote:
> On Tue, Sep 9, 2025 at 4:17 AM Tvrtko Ursulin <tursulin@ursulin.net> wrote:
>>
>>
>> On 08/09/2025 22:15, Thorsten Blum wrote:
>>> Replace kzalloc() followed by copy_from_user() with memdup_user() to
>>> improve and simplify ta_if_load_debugfs_write() and
>>> ta_if_invoke_debugfs_write().
>>>
>>> No functional changes intended.
>>>
>>> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
>>> ---
>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c | 20 ++++++--------------
>>>    1 file changed, 6 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c
>>> index 38face981c3e..6e8aad91bcd3 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c
>>> @@ -171,13 +171,9 @@ static ssize_t ta_if_load_debugfs_write(struct file *fp, const char *buf, size_t
>>>
>>>        copy_pos += sizeof(uint32_t);
>>>
>>> -     ta_bin = kzalloc(ta_bin_len, GFP_KERNEL);
>>> -     if (!ta_bin)
>>> -             return -ENOMEM;
>>> -     if (copy_from_user((void *)ta_bin, &buf[copy_pos], ta_bin_len)) {
>>> -             ret = -EFAULT;
>>> -             goto err_free_bin;
>>> -     }
>>> +     ta_bin = memdup_user(&buf[copy_pos], ta_bin_len);
>>> +     if (IS_ERR(ta_bin))
>>> +             return PTR_ERR(ta_bin);
>>>
>>>        /* Set TA context and functions */
>>>        set_ta_context_funcs(psp, ta_type, &context);
>>> @@ -327,13 +323,9 @@ static ssize_t ta_if_invoke_debugfs_write(struct file *fp, const char *buf, size
>>>                return -EFAULT;
>>>        copy_pos += sizeof(uint32_t);
>>>
>>> -     shared_buf = kzalloc(shared_buf_len, GFP_KERNEL);
>>> -     if (!shared_buf)
>>> -             return -ENOMEM;
>>> -     if (copy_from_user((void *)shared_buf, &buf[copy_pos], shared_buf_len)) {
>>> -             ret = -EFAULT;
>>> -             goto err_free_shared_buf;
>>> -     }
>>> +     shared_buf = memdup_user(&buf[copy_pos], shared_buf_len);
>>> +     if (IS_ERR(shared_buf))
>>> +             return PTR_ERR(shared_buf);
>>>
>>>        set_ta_context_funcs(psp, ta_type, &context);
>>>
>>
>> More complete than the one I sent in June^1.
> 
> I never received this series.  I didn't see it in patchwork either.
> Seems it never made it to amd-gfx.  Sorry I missed it. I've applied
> the applicable patches now.

Thank you and no worries, it wasn't anything urgent.

Regards,

Tvrtko

      reply	other threads:[~2025-09-10 10:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-08 21:15 [PATCH] drm/amdgpu: Replace kzalloc + copy_from_user with memdup_user Thorsten Blum
2025-09-09  8:17 ` Tvrtko Ursulin
2025-09-09 13:36   ` Alex Deucher
2025-09-10 10:09     ` Tvrtko Ursulin [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=d51e11fa-54b0-41f4-9b06-95b46094de39@ursulin.net \
    --to=tursulin@ursulin.net \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=alexdeucher@gmail.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=thorsten.blum@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox