Skip to contentSkip to conversation

drm/amd/display: fix array-bounds error in dc_stream_remove_writeback()

PATCH In review Hamza Mahfooz 5 participants 8 messages Sep 27, 2022 – Oct 11, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_stream.c +1 -1
index 3ca1592ce7ac..ae13887756bf 100644
@@ -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 */
Signature · 1 line
2.37.2
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - General]

--

Regards,
Jay
________________________________
From: Mahfooz, Hamza <[email protected]>
Sent: Tuesday, September 27, 2022 3:12 PM
To: [email protected] <[email protected]>
Cc: Mahfooz, Hamza <[email protected]>; Wentland, Harry <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Siqueira, Rodrigo <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Lee, Alvin <[email protected]>; Hung, Alex <[email protected]>; Kotarac, Pavle <[email protected]>; Wang, Chao-kai (Stylon) <[email protected]>; Pillai, Aurabindo <[email protected]>; Ma, Leo <[email protected]>; Wu, Hersen <[email protected]>; Po-Yu Hsieh Paul <[email protected]>; Jimmy Kizito <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
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.

---
 drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_stream.c +1 -1
index 3ca1592ce7ac..ae13887756bf 100644
@@ -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

#2 lore raw

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];
      |                                 ~~~~~~~~~~~~~~~~~~~~~~^~~

Regards,
  Felix

Am 2022-09-27 um 16:35 schrieb Pillai, Aurabindo:

Quoted 58 lines

[AMD Official Use Only - General]

[AMD Official Use Only - General]

--

Regards,
Jay
------------------------------------------------------------------------
*From:* Mahfooz, Hamza <[email protected]>
*Sent:* Tuesday, September 27, 2022 3:12 PM
*To:* [email protected] <[email protected]>
*Cc:* Mahfooz, Hamza <[email protected]>; Wentland, Harry <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Siqueira, Rodrigo <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Lee, Alvin <[email protected]>; Hung, Alex <[email protected]>; Kotarac, Pavle <[email protected]>; Wang, Chao-kai (Stylon) <[email protected]>; Pillai, Aurabindo <[email protected]>; Ma, Leo <[email protected]>; Wu, Hersen <[email protected]>; Po-Yu Hsieh Paul <[email protected]>; Jimmy Kizito <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]> *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.

---
 drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_stream.c +1 -1
index 3ca1592ce7ac..ae13887756bf 100644
@@ -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 */

Signature · 1 line
2.37.2
#3 lore raw
Quoted 7 lines · Felix Kuehling

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.

Quoted 63 lines

Regards,
  Felix

Am 2022-09-27 um 16:35 schrieb Pillai, Aurabindo:

Quoted 58 lines

[AMD Official Use Only - General]

[AMD Official Use Only - General]

Signature · 29 lines
Regards,
Jay
------------------------------------------------------------------------
*From:* Mahfooz, Hamza <[email protected]>
*Sent:* Tuesday, September 27, 2022 3:12 PM
*To:* [email protected] <[email protected]>
*Cc:* Mahfooz, Hamza <[email protected]>; Wentland, Harry <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Siqueira, Rodrigo <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Lee, Alvin <[email protected]>; Hung, Alex <[email protected]>; Kotarac, Pavle <[email protected]>; Wang, Chao-kai (Stylon) <[email protected]>; Pillai, Aurabindo <[email protected]>; Ma, Leo <[email protected]>; Wu, Hersen <[email protected]>; Po-Yu Hsieh Paul <[email protected]>; Jimmy Kizito <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
*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 <[email protected]>
---
 drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_stream.c +1 -1
index 3ca1592ce7ac..ae13887756bf 100644
@@ -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 */

Signature · 1 line
2.37.2
Signature · 1 line
Hamza
#4 lore raw

Am 2022-09-29 um 11:41 schrieb Hamza Mahfooz:

Quoted 12 lines · Felix Kuehling
Quoted 7 lines

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

Quoted 66 lines
Quoted 65 lines

Regards,
   Felix

Am 2022-09-27 um 16:35 schrieb Pillai, Aurabindo:

Quoted 59 lines

[AMD Official Use Only - General]

[AMD Official Use Only - General]

Signature · 30 lines
Regards,
Jay
------------------------------------------------------------------------ 

*From:* Mahfooz, Hamza <[email protected]>
*Sent:* Tuesday, September 27, 2022 3:12 PM
*To:* [email protected] <[email protected]>
*Cc:* Mahfooz, Hamza <[email protected]>; Wentland, Harry <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Siqueira, Rodrigo <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Lee, Alvin <[email protected]>; Hung, Alex <[email protected]>; Kotarac, Pavle <[email protected]>; Wang, Chao-kai (Stylon) <[email protected]>; Pillai, Aurabindo <[email protected]>; Ma, Leo <[email protected]>; Wu, Hersen <[email protected]>; Po-Yu Hsieh Paul <[email protected]>; Jimmy Kizito <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
*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 <[email protected]>
---
 drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_stream.c +1 -1
index 3ca1592ce7ac..ae13887756bf 100644
@@ -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 */

Signature · 1 line
2.37.2
#5 lore raw
In reply to Hamza Mahfooz
Quoted 13 lines · Hamza Mahfooz

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];
      |
Quoted 5 lines

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.

With gcc 11.3, this patch doesn't fix a problem, it introduces one.

Building csky:allmodconfig ... failed
--------------
Error log:
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:83: error: array subscript 1 is above array bounds of 'struct dc_writeback_info[1]' [-Werror=array-bounds]
527 | stream->writeback_info[j] = stream->writeback_info[i];

Building mips:allmodconfig ... failed
--------------
Error log:
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:83: 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];

Building arm:allmodconfig ... failed
--------------
Error log:
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:83: 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];

Guenter

#6 lore raw
Quoted 36 lines · Guenter Roeck
Quoted 13 lines · Hamza Mahfooz

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];
      |
Quoted 5 lines

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.

With gcc 11.3, this patch doesn't fix a problem, it introduces one.

Building csky:allmodconfig ... failed
--------------
Error log:
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:83: error: array subscript 1 is above array bounds of 'struct dc_writeback_info[1]' [-Werror=array-bounds]
527 | stream->writeback_info[j] = stream->writeback_info[i];

Building mips:allmodconfig ... failed
--------------
Error log:
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:83: 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];

Quoted 7 lines

Building arm:allmodconfig ... failed
--------------
Error log:
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:83: 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];

#regzbot introduced: 5d8c3e836fc2

Complete list of build failures in my test system due to this patch, observed when building with gcc 11.3:

Build results:

	total: 149 pass: 131 fail: 18
Failed builds:
	alpha:allmodconfig
	arm:allmodconfig
	arm64:allmodconfig
	csky:allmodconfig
	i386:allyesconfig
	i386:allmodconfig
	mips:allmodconfig
	openrisc:allmodconfig
	parisc:allmodconfig
	powerpc:allmodconfig
	powerpc:ppc32_allmodconfig
	riscv32:allmodconfig
	riscv:allmodconfig
	s390:allmodconfig
	sparc64:allmodconfig
	x86_64:allyesconfig
	x86_64:allmodconfig
	xtensa:allmodconfig

Guenter

#7 lore raw

[removed a lot of people from the list of recipients, as this is mainly for Guenter]

Hi Guenter!

Quoted 30 lines · Guenter Roeck
Quoted 20 lines · Guenter Roeck
Quoted 13 lines · Hamza Mahfooz

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];
      |
Quoted 5 lines

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.

Quoted 8 lines

With gcc 11.3, this patch doesn't fix a problem, it introduces one.

Building csky:allmodconfig ... failed
--------------
Error log:
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:83: error: array subscript 1 is above array bounds of 'struct dc_writeback_info[1]' [-Werror=array-bounds]
527 | stream->writeback_info[j] = stream->writeback_info[i];

Quoted 3 lines

[...]

#regzbot introduced: 5d8c3e836fc2

Thx for using regzbot, much appreciated. JFYI, the initial report was your own mail you were replying to here, so a "#regzbot ^introduced:
..." would have been more appropriate. In this case it didn't matter anyway, as the fix didn't include a "Link:" tag to the initial report anyway. No worries, I just have to tell regzbot about the fix manually then:

#regzbot fixed-by: faf4d8e07f5b67

Ciao, Thorsten