drivers/mtd/nand/cafe_ecc.c: fix an off-by-one in a BUG_ON
Subsystems (2)
PATCH 1/1 drivers/mtd/nand/cafe_ecc.c: fix an off-by-one in a BUG_ON
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 <[email protected]>
drivers/mtd/nand/cafe_ecc.c renamed from drivers/mtd/nand/cafe_ecc.c.old +1 -1
@@ -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)
David Woodhouse
AppliedQuoted 5 lines · Adrian Bunk
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().
Applied; thanks.
Signature · 1 line
dwmw2