Skip to contentSkip to conversation

sym53c8xx_2: iterator underflow in sym_getsync()

PATCH Applied Dan Carpenter 3 participants 3 messages Jan 25, 2018 – Jan 31, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sym53c8xx_2: iterator underflow in sym_getsync()

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.

drivers/scsi/sym53c8xx_2/sym_hipd.c +1 -1
index ca360daa6a25..378af306fda1 100644
@@ -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;
 
 	/*
#2 lore raw
In reply to Dan Carpenter

Dan,

Quoted 3 lines

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.

Applied to 4.16/scsi-fixes, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering