From: Andrew Morton <akpm@linux-foundation.org>
To: Phil Carmody <ext-phil.2.carmody@nokia.com>
Cc: benh@kernel.crashing.org, roel.kluin@gmail.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hvsi: Messed up error checking getting state name
Date: Fri, 16 Apr 2010 15:18:08 -0700 [thread overview]
Message-ID: <20100416151808.a8a5d340.akpm@linux-foundation.org> (raw)
In-Reply-To: <1271418554-21278-1-git-send-email-ext-phil.2.carmody@nokia.com>
On Fri, 16 Apr 2010 14:49:14 +0300
Phil Carmody <ext-phil.2.carmody@nokia.com> wrote:
> From: Phil Carmody <ext-phil.2.carmody@nokia.com>
>
> Handle out-of-range indices before reading what they refer
> to.
Well... That doesn't matter really - as long as we don't dereference it.
> And don't access the one-past-the-end element of the
> array either.
>
Yup, that's a bug.
> ---
> drivers/char/hvsi.c | 6 ++----
> 1 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c
> index 793b236..d4b14ff 100644
> --- a/drivers/char/hvsi.c
> +++ b/drivers/char/hvsi.c
> @@ -194,10 +194,8 @@ static inline void print_state(struct hvsi_struct *hp)
> "HVSI_WAIT_FOR_MCTRL_RESPONSE",
> "HVSI_FSP_DIED",
> };
> - const char *name = state_names[hp->state];
> -
> - if (hp->state > ARRAY_SIZE(state_names))
> - name = "UNKNOWN";
> + const char *name = (hp->state < ARRAY_SIZE(state_names))
> + ? state_names[hp->state] : "UNKNOWN";
>
> pr_debug("hvsi%i: state = %s\n", hp->index, name);
> #endif /* DEBUG */
> --
> 1.6.0.4
prev parent reply other threads:[~2010-04-16 22:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-16 11:49 [PATCH] hvsi: Messed up error checking getting state name Phil Carmody
2010-04-16 22:18 ` Andrew Morton [this message]
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=20100416151808.a8a5d340.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=ext-phil.2.carmody@nokia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=roel.kluin@gmail.com \
/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