public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] mtd: nand: warn if hamming layout is used with too large ECC
@ 2018-02-08 23:33 Stefan Agner
  2018-02-09  8:50 ` Boris Brezillon
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Agner @ 2018-02-08 23:33 UTC (permalink / raw)
  To: boris.brezillon
  Cc: richard, dwmw2, computersforpeace, linux-mtd, Stefan Agner

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@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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-02-12  9:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-08 23:33 [PATCH] mtd: nand: warn if hamming layout is used with too large ECC Stefan Agner
2018-02-09  8:50 ` Boris Brezillon
2018-02-09  9:20   ` Stefan Agner
2018-02-09  9:34     ` Boris Brezillon
2018-02-09  9:54     ` Boris Brezillon
2018-02-09 11:51       ` Stefan Agner
2018-02-09  9:58     ` Boris Brezillon
2018-02-09 11:55       ` Stefan Agner
2018-02-12  9:34         ` Boris Brezillon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox