Message ID | 54B7AB0A.3020708@ti.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Jan 15, 2015 at 01:56:58PM +0200, Tomi Valkeinen wrote: > > Here's a fix for the cea_array size. Does it silence the static checker? > No. > for (i = specs->modedb_len + num; i < specs->modedb_len + num + svd_n; i++) { > int idx = svd[i - specs->modedb_len - num]; > - if (!idx || idx > 63) { > + if (!idx || idx > 64) { > pr_warning("Reserved SVD code %d\n", idx); > } else if (idx > ARRAY_SIZE(cea_modes) || !cea_modes[idx].xres) { > pr_warning("Unimplemented SVD code %d\n", idx); This static check ignores the value of "idx". It is only looking at "idx > ARRAY_SIZE(cea_modes)" which is off by one and "idx" is used as an index in "!cea_modes[idx].xres". The thinking behind this static checker warnings is that off-by-one bugs are an easy way to boost your patch count even if it's impossible to hit them in real life. :) The value of "idx" is deliberately ignored. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 15/01/15 14:26, Dan Carpenter wrote: > On Thu, Jan 15, 2015 at 01:56:58PM +0200, Tomi Valkeinen wrote: >> >> Here's a fix for the cea_array size. Does it silence the static checker? >> > > No. > >> for (i = specs->modedb_len + num; i < specs->modedb_len + num + svd_n; i++) { >> int idx = svd[i - specs->modedb_len - num]; >> - if (!idx || idx > 63) { >> + if (!idx || idx > 64) { >> pr_warning("Reserved SVD code %d\n", idx); >> } else if (idx > ARRAY_SIZE(cea_modes) || !cea_modes[idx].xres) { >> pr_warning("Unimplemented SVD code %d\n", idx); > > This static check ignores the value of "idx". > > It is only looking at "idx > ARRAY_SIZE(cea_modes)" which is off by one > and "idx" is used as an index in "!cea_modes[idx].xres". Ah, right, I missed that in my patch. The check should obviously be changed to: if (idx >= ARRAY_SIZE(cea_modes) But maybe it would be better to clean up the whole if statement to remove the duplicate check. So in addition to increasing the cea_array size: if (idx == 0 || idx >= ARRAY_SIZE(cea_modes)) { pr_warning("Reserved SVD code %d\n", idx); } else if (!cea_modes[idx].xres) { pr_warning("Unimplemented SVD code %d\n", idx); Tomi
Sounds good to me. :) Could I get a Reported-by cookie? regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/video/fbdev/core/fbmon.c b/drivers/video/fbdev/core/fbmon.c index 5b0e313849bd..0fea923c3cb6 100644 --- a/drivers/video/fbdev/core/fbmon.c +++ b/drivers/video/fbdev/core/fbmon.c @@ -1059,7 +1059,7 @@ void fb_edid_add_monspecs(unsigned char *edid, struct fb_monspecs *specs) for (i = specs->modedb_len + num; i < specs->modedb_len + num + svd_n; i++) { int idx = svd[i - specs->modedb_len - num]; - if (!idx || idx > 63) { + if (!idx || idx > 64) { pr_warning("Reserved SVD code %d\n", idx); } else if (idx > ARRAY_SIZE(cea_modes) || !cea_modes[idx].xres) { pr_warning("Unimplemented SVD code %d\n", idx); diff --git a/drivers/video/fbdev/core/modedb.c b/drivers/video/fbdev/core/modedb.c index 388f7971494b..b2aba4e3150a 100644 --- a/drivers/video/fbdev/core/modedb.c +++ b/drivers/video/fbdev/core/modedb.c @@ -289,7 +289,7 @@ static const struct fb_videomode modedb[] = { }; #ifdef CONFIG_FB_MODE_HELPERS -const struct fb_videomode cea_modes[64] = { +const struct fb_videomode cea_modes[65] = { /* #1: 640x480p@59.94/60Hz */ [1] = { NULL, 60, 640, 480, 39722, 48, 16, 33, 10, 96, 2, 0, diff --git a/include/linux/fb.h b/include/linux/fb.h index 09bb7a18d287..024260687698 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -779,7 +779,7 @@ struct fb_videomode { extern const char *fb_mode_option; extern const struct fb_videomode vesa_modes[]; -extern const struct fb_videomode cea_modes[64]; +extern const struct fb_videomode cea_modes[65]; struct fb_modelist { struct list_head list;