osst: fix read buffer overflow
authorRoel Kluin <roel.kluin@gmail.com>
Wed, 11 Aug 2010 01:01:10 +0000 (18:01 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 11 Aug 2010 15:58:59 +0000 (08:58 -0700)
Check whether index is within bounds before testing the element.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Cc: Willem Riede <osst@riede.org>
Cc: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/scsi/osst.c

index d64b7178fa088a3eb24453affaa6e5782037d195..278b352ae78d0bdc6d5609f7d62bfc9893111a00 100644 (file)
@@ -5868,7 +5868,8 @@ static int osst_probe(struct device *dev)
        }
 
        /* find a free minor number */
-       for (i=0; os_scsi_tapes[i] && i<osst_max_dev; i++);
+       for (i = 0; i < osst_max_dev && os_scsi_tapes[i]; i++)
+               ;
        if(i >= osst_max_dev) panic ("Scsi_devices corrupt (osst)");
        dev_num = i;