Skip to content

Commit

Permalink
[MTD] [NAND] Fix an off-by-one in a BUG_ON in CAFÉ ECC correction.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Adrian Bunk authored and David Woodhouse committed Feb 9, 2007
1 parent 0373615 commit d24030f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/mtd/nand/cafe_ecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d24030f

Please sign in to comment.