On 2019/2/1 16:30, Dan Carpenter wrote:
There is a sizeof() vs ARRAY_SIZE() bug here. We want the number of
elements in the array, not the number of bytes. It means we potentially
read beyond the end of the array.
Fixes: 2d570b34b41a ("mtd: rawnand: meson: add support for Amlogic NAND flash controller")
Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
---
drivers/mtd/nand/raw/meson_nand.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c
index 94c90be7e1e0..0d93d0b9c1af 100644
--- a/drivers/mtd/nand/raw/meson_nand.c
+++ b/drivers/mtd/nand/raw/meson_nand.c
@@ -1143,7 +1143,7 @@ static int meson_nand_bch_mode(struct nand_chip *nand)
if (nand->ecc.strength > 60 || nand->ecc.strength < 8)
return -EINVAL;
- for (i = 0; i < sizeof(meson_ecc); i++) {
+ for (i = 0; i < ARRAY_SIZE(meson_ecc); i++) {
ok.
Acked-by: Liang Yang <liang.yang@xxxxxxxxxxx>
if (meson_ecc[i].strength == nand->ecc.strength) {
meson_chip->bch_mode = meson_ecc[i].bch;
return 0;
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/