]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[MTD] [NAND] Fix an off-by-one in a BUG_ON in CAFÉ ECC correction.
authorAdrian Bunk <bunk@stusta.de>
Fri, 2 Feb 2007 14:29:19 +0000 (15:29 +0100)
committerDavid Woodhouse <dwmw2@infradead.org>
Fri, 9 Feb 2007 15:06:02 +0000 (15:06 +0000)
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>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
drivers/mtd/nand/cafe_ecc.c

index 1b9fa05a44747fdb7eeb9bb9049dc47e6131edf1..ea5c8491d2c57677250b012f1d9261494cead565 100644 (file)
@@ -1045,7 +1045,7 @@ static unsigned short err_pos_lut[4096] = {
 
 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)