kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [SCSI] sym53c8xx_2: iterator underflow in sym_getsync()
@ 2018-01-25 14:13 Dan Carpenter
  2018-01-29 14:51 ` Johannes Thumshirn
  2018-01-31  2:29 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2018-01-25 14:13 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: James E.J. Bottomley, Martin K. Petersen, linux-scsi,
	kernel-janitors, Arnd Bergmann

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>

diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c
index ca360daa6a25..378af306fda1 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.c
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c
@@ -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;
 
 	/*

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-31  2:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-25 14:13 [PATCH] [SCSI] sym53c8xx_2: iterator underflow in sym_getsync() Dan Carpenter
2018-01-29 14:51 ` Johannes Thumshirn
2018-01-31  2:29 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).