From: Felix Kuehling <felix.kuehling@amd.com>
To: Hamza Mahfooz <hamza.mahfooz@amd.com>,
"Pillai, Aurabindo" <Aurabindo.Pillai@amd.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "Wang, Chao-kai (Stylon)" <Stylon.Wang@amd.com>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"Li, Sun peng (Leo)" <Sunpeng.Li@amd.com>,
Po-Yu Hsieh Paul <Paul.Hsieh@amd.com>,
"Pan, Xinhui" <Xinhui.Pan@amd.com>,
"Siqueira, Rodrigo" <Rodrigo.Siqueira@amd.com>,
"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
David Airlie <airlied@linux.ie>, "Hung, Alex" <Alex.Hung@amd.com>,
"Lee, Alvin" <Alvin.Lee2@amd.com>,
"Deucher, Alexander" <Alexander.Deucher@amd.com>,
"Wu, Hersen" <hersenxs.wu@amd.com>,
"Ma, Leo" <Hanghong.Ma@amd.com>,
Jimmy Kizito <Jimmy.Kizito@amd.com>,
"Koenig, Christian" <Christian.Koenig@amd.com>,
"Kotarac, Pavle" <Pavle.Kotarac@amd.com>
Subject: Re: [PATCH] drm/amd/display: fix array-bounds error in dc_stream_remove_writeback()
Date: Thu, 29 Sep 2022 12:05:26 -0400 [thread overview]
Message-ID: <36ad5d1c-b841-03bb-14cf-0b459df47749@amd.com> (raw)
In-Reply-To: <4b21a150-a567-dafa-1a55-8496cdb0cec6@amd.com>
Am 2022-09-29 um 11:41 schrieb Hamza Mahfooz:
>
>
> On 2022-09-29 11:36, Felix Kuehling wrote:
>> I'm still seeing a warning even with this fix:
>>
>> /home/fkuehlin/compute/kernel/drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_stream.c:
>> In function ?dc_stream_remove_writeback?:
>> /home/fkuehlin/compute/kernel/drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_stream.c:527:55:
>> warning: array subscript 1 is above array bounds of ?struct
>> dc_writeback_info[1]? [-Warray-bounds]
>> 527 | stream->writeback_info[j] = stream->writeback_info[i];
>> | ~~~~~~~~~~~~~~~~~~~~~~^~~
>>
>
> What version of GCC are you using? I don't see it on GCC 12.2 with
> this patch applied.
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Regards,
Felix
>
>> Regards,
>> Felix
>>
>>
>> Am 2022-09-27 um 16:35 schrieb Pillai, Aurabindo:
>>>
>>> [AMD Official Use Only - General]
>>>
>>>
>>> [AMD Official Use Only - General]
>>>
>>>
>>> Reviewed-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
>>>
>>> --
>>>
>>> Regards,
>>> Jay
>>> ------------------------------------------------------------------------
>>>
>>> *From:* Mahfooz, Hamza <Hamza.Mahfooz@amd.com>
>>> *Sent:* Tuesday, September 27, 2022 3:12 PM
>>> *To:* linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>
>>> *Cc:* Mahfooz, Hamza <Hamza.Mahfooz@amd.com>; Wentland, Harry
>>> <Harry.Wentland@amd.com>; Li, Sun peng (Leo) <Sunpeng.Li@amd.com>;
>>> Siqueira, Rodrigo <Rodrigo.Siqueira@amd.com>; Deucher, Alexander
>>> <Alexander.Deucher@amd.com>; Koenig, Christian
>>> <Christian.Koenig@amd.com>; Pan, Xinhui <Xinhui.Pan@amd.com>; David
>>> Airlie <airlied@linux.ie>; Daniel Vetter <daniel@ffwll.ch>; Lee,
>>> Alvin <Alvin.Lee2@amd.com>; Hung, Alex <Alex.Hung@amd.com>; Kotarac,
>>> Pavle <Pavle.Kotarac@amd.com>; Wang, Chao-kai (Stylon)
>>> <Stylon.Wang@amd.com>; Pillai, Aurabindo <Aurabindo.Pillai@amd.com>;
>>> Ma, Leo <Hanghong.Ma@amd.com>; Wu, Hersen <hersenxs.wu@amd.com>;
>>> Po-Yu Hsieh Paul <Paul.Hsieh@amd.com>; Jimmy Kizito
>>> <Jimmy.Kizito@amd.com>; amd-gfx@lists.freedesktop.org
>>> <amd-gfx@lists.freedesktop.org>; dri-devel@lists.freedesktop.org
>>> <dri-devel@lists.freedesktop.org>
>>> *Subject:* [PATCH] drm/amd/display: fix array-bounds error in
>>> dc_stream_remove_writeback()
>>> Address the following error:
>>> drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_stream.c: In
>>> function ‘dc_stream_remove_writeback’:
>>> drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_stream.c:527:55:
>>> error: array subscript [0, 0] is outside array bounds of ‘struct
>>> dc_writeback_info[1]’ [-Werror=array-bounds]
>>> 527 | stream->writeback_info[j] = stream->writeback_info[i];
>>> | ~~~~~~~~~~~~~~~~~~~~~~^~~
>>> In file included from
>>> ./drivers/gpu/drm/amd/amdgpu/../display/dc/dc.h:1269,
>>> from
>>> ./drivers/gpu/drm/amd/amdgpu/../display/dc/inc/core_types.h:29,
>>> from
>>> ./drivers/gpu/drm/amd/amdgpu/../display/dc/basics/dc_common.h:29,
>>> from
>>> drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_stream.c:27:
>>> ./drivers/gpu/drm/amd/amdgpu/../display/dc/dc_stream.h:241:34: note:
>>> while referencing ‘writeback_info’
>>> 241 | struct dc_writeback_info writeback_info[MAX_DWB_PIPES];
>>> |
>>>
>>> Currently, we aren't checking to see if j remains within
>>> writeback_info[]'s bounds. So, add a check to make sure that we aren't
>>> overflowing the buffer.
>>>
>>> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
>>> ---
>>> drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
>>> b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
>>> index 3ca1592ce7ac..ae13887756bf 100644
>>> --- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
>>> +++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
>>> @@ -520,7 +520,7 @@ bool dc_stream_remove_writeback(struct dc *dc,
>>> }
>>>
>>> /* remove writeback info for disabled writeback pipes from
>>> stream */
>>> - for (i = 0, j = 0; i < stream->num_wb_info; i++) {
>>> + for (i = 0, j = 0; i < stream->num_wb_info && j <
>>> MAX_DWB_PIPES; i++) {
>>> if (stream->writeback_info[i].wb_enabled) {
>>> if (i != j)
>>> /* trim the array */
>>> --
>>> 2.37.2
>>>
>
next prev parent reply other threads:[~2022-09-29 16:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-27 19:12 [PATCH] drm/amd/display: fix array-bounds error in dc_stream_remove_writeback() Hamza Mahfooz
[not found] ` <CH0PR12MB5284EAC9E9D095B2624631228B559@CH0PR12MB5284.namprd12.prod.outlook.com>
2022-09-29 15:36 ` Felix Kuehling
2022-09-29 15:41 ` Hamza Mahfooz
2022-09-29 16:05 ` Felix Kuehling [this message]
2022-10-06 6:46 ` Guenter Roeck
2022-10-06 17:23 ` Guenter Roeck
2022-10-11 9:49 ` Thorsten Leemhuis
2022-11-08 10:55 wangkailong
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=36ad5d1c-b841-03bb-14cf-0b459df47749@amd.com \
--to=felix.kuehling@amd.com \
--cc=Alex.Hung@amd.com \
--cc=Alexander.Deucher@amd.com \
--cc=Alvin.Lee2@amd.com \
--cc=Aurabindo.Pillai@amd.com \
--cc=Christian.Koenig@amd.com \
--cc=Hanghong.Ma@amd.com \
--cc=Jimmy.Kizito@amd.com \
--cc=Paul.Hsieh@amd.com \
--cc=Pavle.Kotarac@amd.com \
--cc=Rodrigo.Siqueira@amd.com \
--cc=Stylon.Wang@amd.com \
--cc=Sunpeng.Li@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@linux.ie \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=hamza.mahfooz@amd.com \
--cc=hersenxs.wu@amd.com \
--cc=linux-kernel@vger.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;
as well as URLs for NNTP newsgroup(s).