From: "Christian König" <christian.koenig@amd.com>
To: Jesse Zhang <jesse.zhang@amd.com>, amd-gfx@lists.freedesktop.org
Cc: Alexander.Deucher@amd.com, Tim.Huang@amd.com
Subject: Re: [PATCH] drm/amdgpu: fix the warning about the expression (int)size - len
Date: Thu, 25 Apr 2024 08:46:03 +0200 [thread overview]
Message-ID: <00c52cab-d933-4622-bad4-d291f680f68e@amd.com> (raw)
In-Reply-To: <20240425062035.905275-1-jesse.zhang@amd.com>
Am 25.04.24 um 08:20 schrieb Jesse Zhang:
> Converting size from size_t to int may overflow.
>
> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> index f5d0fa207a88..b828aad4f35e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> @@ -2065,12 +2065,13 @@ static ssize_t amdgpu_reset_dump_register_list_write(struct file *f,
> struct amdgpu_device *adev = (struct amdgpu_device *)file_inode(f)->i_private;
> char reg_offset[11];
> uint32_t *new = NULL, *tmp = NULL;
> - int ret, i = 0, len = 0;
> + int ret, i = 0;
> + unsigned int len = 0;
Please keep reverse xmas tree order here, apart from that looks good to me.
Regards,
Christian.
>
> do {
> memset(reg_offset, 0, 11);
> if (copy_from_user(reg_offset, buf + len,
> - min(10, ((int)size-len)))) {
> + min(10, (size-len)))) {
> ret = -EFAULT;
> goto error_free;
> }
next prev parent reply other threads:[~2024-04-25 6:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-25 6:20 [PATCH] drm/amdgpu: fix the warning about the expression (int)size - len Jesse Zhang
2024-04-25 6:46 ` Christian König [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-04-25 7:17 Jesse Zhang
2024-04-25 13:29 ` Alex Deucher
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=00c52cab-d933-4622-bad4-d291f680f68e@amd.com \
--to=christian.koenig@amd.com \
--cc=Alexander.Deucher@amd.com \
--cc=Tim.Huang@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=jesse.zhang@amd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.