scsi: sym53c8xx_2: iterator underflow in sym_getsync()
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 25 Jan 2018 14:13:40 +0000 (17:13 +0300)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 31 Jan 2018 02:29:16 +0000 (21:29 -0500)
We wanted to exit the loop with "div" set to zero, but instead, if we
don't hit the break then "div" is -1 when we finish the loop.  It leads
to an array underflow a few lines later.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Acked-by: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/sym53c8xx_2/sym_hipd.c

index ca360da..378af30 100644 (file)
@@ -536,7 +536,7 @@ sym_getsync(struct sym_hcb *np, u_char dt, u_char sfac, u_char *divp, u_char *fa
         *  Look for the greatest clock divisor that allows an 
         *  input speed faster than the period.
         */
-       while (div-- > 0)
+       while (--div > 0)
                if (kpc >= (div_10M[div] << 2)) break;
 
        /*