[PATCH] rio: fix array checking

From: Alan Cox
Date: Mon Oct 16 2006 - 11:02:20 EST


Found by an analysis tool and reported to the list. Fix is simple enough

Signed-off-by: Alan Cox <alan@xxxxxxxxxx>

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.19-rc1-mm1/drivers/char/rio/rioctrl.c linux-2.6.19-rc1-mm1/drivers/char/rio/rioctrl.c
--- linux.vanilla-2.6.19-rc1-mm1/drivers/char/rio/rioctrl.c 2006-10-13 15:06:33.000000000 +0100
+++ linux-2.6.19-rc1-mm1/drivers/char/rio/rioctrl.c 2006-10-14 18:55:37.000000000 +0100
@@ -662,7 +662,7 @@
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
}
- if (portStats.port >= RIO_PORTS) {
+ if (portStats.port < 0 || portStats.port >= RIO_PORTS) {
p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
return -ENXIO;
}
@@ -702,7 +702,7 @@
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
}
- if (portStats.port >= RIO_PORTS) {
+ if (portStats.port < 0 || portStats.port >= RIO_PORTS) {
p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
return -ENXIO;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/