public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] gru: fix a sanity test in gru_set_context_option()
@ 2013-05-19 12:59 Dan Carpenter
  2013-05-19 14:44 ` Dimitri Sivanich
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2013-05-19 12:59 UTC (permalink / raw)
  To: Dimitri Sivanich; +Cc: Robin Holt, linux-kernel, kernel-janitors

"req.val1 == -1" is valid but it doesn't make sense to check
gru_base[-1].  gru_base[] is a global array.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/misc/sgi-gru/grufault.c b/drivers/misc/sgi-gru/grufault.c
index c4acac7..e7c37b2 100644
--- a/drivers/misc/sgi-gru/grufault.c
+++ b/drivers/misc/sgi-gru/grufault.c
@@ -876,7 +876,8 @@ int gru_set_context_option(unsigned long arg)
 	switch (req.op) {
 	case sco_blade_chiplet:
 		/* Select blade/chiplet for GRU context */
-		if (req.val1 < -1 || req.val1 >= GRU_MAX_BLADES || !gru_base[req.val1] ||
+		if (req.val1 < -1 || req.val1 >= GRU_MAX_BLADES ||
+		    (req.val1 != -1 && !gru_base[req.val1]) ||
 		    req.val0 < -1 || req.val0 >= GRU_CHIPLETS_PER_HUB) {
 			ret = -EINVAL;
 		} else {

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-05-20 18:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-19 12:59 [patch] gru: fix a sanity test in gru_set_context_option() Dan Carpenter
2013-05-19 14:44 ` Dimitri Sivanich
2013-05-19 18:30   ` Dan Carpenter
2013-05-20 13:46     ` Dimitri Sivanich
2013-05-20 18:06       ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox