From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: linux-fbdev@vger.kernel.org
Subject: Re: [patch] fbdev: off by one test (harmless)
Date: Thu, 15 Jan 2015 12:39:01 +0000 [thread overview]
Message-ID: <54B7B4E5.2070904@ti.com> (raw)
In-Reply-To: <20141226172657.GA14762@mwanda>
[-- Attachment #1: Type: text/plain, Size: 1240 bytes --]
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
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-01-15 12:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-26 17:26 [patch] fbdev: off by one test (harmless) Dan Carpenter
2014-12-27 1:29 ` Jingoo Han
2014-12-29 21:51 ` David Ung
2015-01-13 11:19 ` Tomi Valkeinen
2015-01-14 5:24 ` David Ung
2015-01-15 11:42 ` Tomi Valkeinen
2015-01-15 11:56 ` Tomi Valkeinen
2015-01-15 12:26 ` Dan Carpenter
2015-01-15 12:39 ` Tomi Valkeinen [this message]
2015-01-15 12:43 ` Dan Carpenter
2015-01-15 12:52 ` Tomi Valkeinen
2015-07-23 12:39 ` Dan Carpenter
2015-08-10 9:38 ` Tomi Valkeinen
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=54B7B4E5.2070904@ti.com \
--to=tomi.valkeinen@ti.com \
--cc=linux-fbdev@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.