[PATCH V2] drm/amdgpu: fix the warning about the expression (int)size - len
Christian König
christian.koenig at amd.com
Thu Apr 25 07:16:33 UTC 2024
Am 25.04.24 um 09:11 schrieb Jesse Zhang:
> Converting size from size_t to int may overflow.
> v2: keep reverse xmas tree order (Christian)
>
> Signed-off-by: Jesse Zhang <Jesse.Zhang at amd.com>
>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> index f5d0fa207a88..eed60d4b3390 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;
> + unsigned int len = 0;
> int ret, i = 0, len = 0;
Well now you have len defined twice :)
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;
> }
More information about the amd-gfx
mailing list