Skip to content

Commit

Permalink
[PATCH] rio: fix array checking
Browse files Browse the repository at this point in the history
Found by an analysis tool and reported to the list. Fix is simple enough

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Alan Cox authored and Linus Torvalds committed Oct 16, 2006
1 parent 51018b0 commit 9d90daf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/char/rio/rioctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su
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;
}
Expand Down Expand Up @@ -702,7 +702,7 @@ int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su
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;
}
Expand Down

0 comments on commit 9d90daf

Please sign in to comment.