]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
drivers/misc/sgi-gru/grufault.c: fix a sanity test in gru_set_context_option()
authorDimitri Sivanich <sivanich@sgi.com>
Fri, 7 Jun 2013 00:08:40 +0000 (10:08 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 7 Jun 2013 05:42:42 +0000 (15:42 +1000)
"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: Dimitri Sivanich <sivanich@sgi.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Robin Holt <holt@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/misc/sgi-gru/grufault.c

index c4acac74725c4de50ef0954a258a851c05a03930..f74fc0ca2ef9b86fbb85807ebcc9a9e3bae433fb 100644 (file)
@@ -876,8 +876,9 @@ 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] ||
-                   req.val0 < -1 || req.val0 >= GRU_CHIPLETS_PER_HUB) {
+               if (req.val0 < -1 || req.val0 >= GRU_CHIPLETS_PER_HUB ||
+                   req.val1 < -1 || req.val1 >= GRU_MAX_BLADES ||
+                   (req.val1 >= 0 && !gru_base[req.val1])) {
                        ret = -EINVAL;
                } else {
                        gts->ts_user_blade_id = req.val1;