RE: [PATCH v2] drm/amdgpu: fix overflowed array index read warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[AMD Official Use Only - General]

-----Original Message-----
From: Koenig, Christian <Christian.Koenig@xxxxxxx>
Sent: Thursday, April 25, 2024 9:31 PM
To: Alex Deucher <alexdeucher@xxxxxxxxx>; Huang, Tim <Tim.Huang@xxxxxxx>
Cc: amd-gfx@xxxxxxxxxxxxxxxxxxxxx; Deucher, Alexander <Alexander.Deucher@xxxxxxx>
Subject: Re: [PATCH v2] drm/amdgpu: fix overflowed array index read warning

Am 25.04.24 um 15:28 schrieb Alex Deucher:
> On Thu, Apr 25, 2024 at 3:22 AM Tim Huang <tim.huang@xxxxxxx> wrote:
>> From: Tim Huang <Tim.Huang@xxxxxxx>
>>
>> Clear warning that cast operation might have overflowed.
>>
>> v2: keep reverse xmas tree order to declare "int r;" (Christian)
>>
>> Signed-off-by: Tim Huang <Tim.Huang@xxxxxxx>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
>> index 06f0a6534a94..8cf60acb2970 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
>> @@ -473,8 +473,8 @@ static ssize_t amdgpu_debugfs_ring_read(struct file *f, char __user *buf,
>>                                          size_t size, loff_t *pos)
>>   {
>>          struct amdgpu_ring *ring = file_inode(f)->i_private;
>> -       int r, i;
>>          uint32_t value, result, early[3];
>> +       int r;
>>
>>          if (*pos & 3 || size & 3)
>>                  return -EINVAL;
>> @@ -485,7 +485,7 @@ static ssize_t amdgpu_debugfs_ring_read(struct file *f, char __user *buf,
>>                  early[0] = amdgpu_ring_get_rptr(ring) & ring->buf_mask;
>>                  early[1] = amdgpu_ring_get_wptr(ring) & ring->buf_mask;
>>                  early[2] = ring->wptr & ring->buf_mask;
>> -               for (i = *pos / 4; i < 3 && size; i++) {
>> +               for (loff_t i = *pos / 4; i < 3 && size; i++) {
> Some older compilers complain about declarations mixed with code like
> this.  Not sure how big a deal that would be.

>Good point, we would like to be able to backport this.

>Somebody from Alivins team needs to comment, but IIRC we agreed that this would be legal and we take care of it by using appropriate compiler flags on older kernels.

>Christian.

Thanks for pointing out. Will avoid doing this.

>
> Alex
>
>>                          r = put_user(early[i], (uint32_t *)buf);
>>                          if (r)
>>                                  return r;
>> --
>> 2.39.2
>>





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux