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

* Re: [PATCH] [SCSI] sym53c8xx_2: iterator underflow in sym_getsync()
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2018-01-29 14:51 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Matthew Wilcox, James E.J. Bottomley, Martin K. Petersen,
	linux-scsi, kernel-janitors, Arnd Bergmann

Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

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

* Re: [PATCH] [SCSI] sym53c8xx_2: iterator underflow in sym_getsync()
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2018-01-31  2:29 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Matthew Wilcox, James E.J. Bottomley, Martin K. Petersen,
	linux-scsi, kernel-janitors, Arnd Bergmann


Dan,

> 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!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[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).