[PATCH] mtd: nand: warn if hamming layout is used with too large ECC
Stefan Agner
stefan at agner.ch
Thu Feb 8 15:33:05 PST 2018
Warn in case a driver uses too large ECC with hamming layout.
This is especially helpful since hamming layout is the default
layout when using hardware ECC and no specific OOB layout is
specified.
Signed-off-by: Stefan Agner <stefan at agner.ch>
---
drivers/mtd/nand/nand_base.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 96c97588e1ba..2f3f43d0e288 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -197,6 +197,8 @@ static int nand_ooblayout_free_lp_hamming(struct mtd_info *mtd, int section,
return -EINVAL;
}
+ WARN_ON(mtd->oobsize - ecc_offset < ecc->total);
+
if (section == 0) {
oobregion->offset = 2;
oobregion->length = ecc_offset - 2;
--
2.16.1
More information about the linux-mtd
mailing list