aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/hvsi.c
diff options
context:
space:
mode:
authorPhil Carmody <ext-phil.2.carmody@nokia.com>2010-05-24 17:33:04 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-05-25 11:07:03 -0400
commit08a82c6872ac1d37cb993a52f1b35f97f48295bd (patch)
tree43599b0869e8001e3e207e3498a5d510720070f2 /drivers/char/hvsi.c
parent4be929be34f9bdeffa40d815d32d7d60d2c7f03b (diff)
hvsi: fix messed up error checking getting state name
Handle out-of-range indices before reading what they refer to. And don't access the one-past-the-end element of the array either. Signed-off-by: Phil Carmody <ext-phil.2.carmody@nokia.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Roel Kluin <roel.kluin@gmail.com> Cc: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/hvsi.c')
-rw-r--r--drivers/char/hvsi.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c
index 793b236c9266..d4b14ff1c4c1 100644
--- a/drivers/char/hvsi.c
+++ b/drivers/char/hvsi.c
@@ -194,10 +194,8 @@ static inline void print_state(struct hvsi_struct *hp)
194 "HVSI_WAIT_FOR_MCTRL_RESPONSE", 194 "HVSI_WAIT_FOR_MCTRL_RESPONSE",
195 "HVSI_FSP_DIED", 195 "HVSI_FSP_DIED",
196 }; 196 };
197 const char *name = state_names[hp->state]; 197 const char *name = (hp->state < ARRAY_SIZE(state_names))
198 198 ? state_names[hp->state] : "UNKNOWN";
199 if (hp->state > ARRAY_SIZE(state_names))
200 name = "UNKNOWN";
201 199
202 pr_debug("hvsi%i: state = %s\n", hp->index, name); 200 pr_debug("hvsi%i: state = %s\n", hp->index, name);
203#endif /* DEBUG */ 201#endif /* DEBUG */