Skip to contentSkip to conversation

drivers/gpu/drm/drm_edid.c:1303: warning: array subscript is above array bounds

2.6.37-rc7 Jarek Poplawski 2 participants 3 messages Dec 25, 2010

lore
Share & tools
lore
#0 lore raw

Hi,
There is this compile warning in Linus' tree (gcc version 4.3.3):

drivers/gpu/drm/drm_edid.c: In function 'drm_detect_hdmi_monitor':
drivers/gpu/drm/drm_edid.c:1303: warning: array subscript is above array bounds drivers/gpu/drm/drm_edid.c: In function 'drm_detect_monitor_audio':
drivers/gpu/drm/drm_edid.c:1303: warning: array subscript is above array bounds

Cheers,
Jarek P.

#1 lore raw
Quoted 7 lines · Jarek Poplawski

Hi,
There is this compile warning in Linus' tree (gcc version 4.3.3):

drivers/gpu/drm/drm_edid.c: In function 'drm_detect_hdmi_monitor':
drivers/gpu/drm/drm_edid.c:1303: warning: array subscript is above array bounds drivers/gpu/drm/drm_edid.c: In function 'drm_detect_monitor_audio':
drivers/gpu/drm/drm_edid.c:1303: warning: array subscript is above array bounds

What array? It's declared as "u8 *edid_ext;". At first glance looks like a compiler bug, applying subscript testing to an object with unknown bounds. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#2 lore raw
Quoted 11 lines · Chris Wilson
Quoted 7 lines · Jarek Poplawski

Hi,
There is this compile warning in Linus' tree (gcc version 4.3.3):

drivers/gpu/drm/drm_edid.c: In function 'drm_detect_hdmi_monitor':
drivers/gpu/drm/drm_edid.c:1303: warning: array subscript is above array bounds drivers/gpu/drm/drm_edid.c: In function 'drm_detect_monitor_audio':
drivers/gpu/drm/drm_edid.c:1303: warning: array subscript is above array bounds

What array? It's declared as "u8 *edid_ext;". At first glance looks like a compiler bug, applying subscript testing to an object with unknown bounds.

Maybe a bug but then also something very unique in this place wrt the rest of the kernel (at least in my config). Btw, a patch below removes this warning.

Jarek P.

drm_edid.c renamed from drm_edid.c- +2 -2
@@ -1290,7 +1290,7 @@ add_detailed_modes(struct drm_connector 
  */
 static u8 *drm_find_cea_extension(struct edid *edid)
 {
-	u8 *edid_ext = NULL;
+	char *edid_ext = NULL;
 	int i;
 
 	/* No EDID or EDID extensions */
@@ -1299,7 +1299,7 @@ static u8 *drm_find_cea_extension(struct
 
 	/* Find CEA extension */
 	for (i = 0; i < edid->extensions; i++) {
-		edid_ext = (u8 *)edid + EDID_LENGTH * (i + 1);
+		edid_ext = (char *)edid + EDID_LENGTH * (i + 1);
 		if (edid_ext[0] == CEA_EXT)
 			break;
 	}