public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ubi: Reject MLC NAND
@ 2018-03-03 10:45 Richard Weinberger
  2018-03-04 19:46 ` Boris Brezillon
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Richard Weinberger @ 2018-03-03 10:45 UTC (permalink / raw)
  To: linux-mtd
  Cc: linux-kernel, cyrille.pitchen, marek.vasut, boris.brezillon,
	computersforpeace, dwmw2, richard, dedekind1, tharvey, stable

While UBI and UBIFS seem to work at first sight with MLC NAND, you will
most likely lose all your data upon a power-cut or due to read/write
disturb.
In order to protect users from bad surprises, refuse to attach to MLC
NAND.

Cc: stable@vger.kernel.org
Signed-off-by: Richard Weinberger <richard@nod.at>
---
 drivers/mtd/ubi/build.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index e941395de3ae..753494e042d5 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -854,6 +854,17 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
 		return -EINVAL;
 	}
 
+	/*
+	 * Both UBI and UBIFS have been designed for SLC NAND and NOR flashes.
+	 * MLC NAND is different and needs special care, otherwise UBI or UBIFS
+	 * will die soon and you will lose all your data.
+	 */
+	if (mtd->type == MTD_MLCNANDFLASH) {
+		pr_err("ubi: refuse attaching mtd%d - MLC NAND is not supported\n",
+			mtd->index);
+		return -EINVAL;
+	}
+
 	if (ubi_num == UBI_DEV_NUM_AUTO) {
 		/* Search for an empty slot in the @ubi_devices array */
 		for (ubi_num = 0; ubi_num < UBI_MAX_DEVICES; ubi_num++)
-- 
2.13.6

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

end of thread, other threads:[~2018-03-08 15:34 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-03 10:45 [PATCH] ubi: Reject MLC NAND Richard Weinberger
2018-03-04 19:46 ` Boris Brezillon
2018-03-06 23:18 ` Pavel Machek
2018-03-07  1:57   ` David Oberhollenzer
2018-03-07  8:01   ` Richard Weinberger
2018-03-07 15:24     ` Artem Bityutskiy
2018-03-07 21:43     ` Pavel Machek
2018-03-07 22:08       ` Steve deRosier
2018-03-07 22:11         ` David Woodhouse
2018-03-07 22:17           ` Pavel Machek
2018-03-07 22:30             ` Boris Brezillon
2018-03-07 23:27               ` Willy Tarreau
2018-03-07 22:40       ` Boris Brezillon
2018-03-08 13:42 ` Linus Walleij
2018-03-08 14:43   ` Richard Weinberger
2018-03-08 15:01     ` Artem Bityutskiy
2018-03-08 15:28       ` Richard Weinberger
2018-03-08 15:34         ` Artem Bityutskiy

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