public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [2.6 patch] drivers/mtd/nand/cafe_ecc.c: fix an off-by-one in a BUG_ON
@ 2007-02-02 14:29 Adrian Bunk
  2007-02-09 15:06 ` David Woodhouse
  0 siblings, 1 reply; 2+ messages in thread
From: Adrian Bunk @ 2007-02-02 14:29 UTC (permalink / raw)
  To: dwmw2; +Cc: linux-mtd

err_pos_lut[4096] of an array with 4096 elements is a bug.

Spotted by the Coverity checker.

While I was at it, I also converted it to ARRAY_SIZE().

Signed-off-by: Adrian Bunk <bunk@stusta.de>

--- linux-2.6.20-rc6-mm3/drivers/mtd/nand/cafe_ecc.c.old	2007-02-02 14:45:13.000000000 +0100
+++ linux-2.6.20-rc6-mm3/drivers/mtd/nand/cafe_ecc.c	2007-02-02 14:45:42.000000000 +0100
@@ -1045,7 +1045,7 @@
 
 static unsigned short err_pos(unsigned short din)
 {
-	BUG_ON(din > 4096);
+	BUG_ON(din >= ARRAY_SIZE(err_pos_lut));
 	return err_pos_lut[din];
 }
 static int chk_no_err_only(unsigned short *chk_syndrome_list, unsigned short *err_info)

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

end of thread, other threads:[~2007-02-09 15:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-02 14:29 [2.6 patch] drivers/mtd/nand/cafe_ecc.c: fix an off-by-one in a BUG_ON Adrian Bunk
2007-02-09 15:06 ` David Woodhouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox