Skip to content

Commit b5094b7

Browse files
ubi: Reject MLC NAND
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: [email protected] Signed-off-by: Richard Weinberger <[email protected]> Acked-by: Boris Brezillon <[email protected]> Acked-by: Artem Bityutskiy <[email protected]>
1 parent 4fb1cd8 commit b5094b7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/mtd/ubi/build.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,17 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
854854
return -EINVAL;
855855
}
856856

857+
/*
858+
* Both UBI and UBIFS have been designed for SLC NAND and NOR flashes.
859+
* MLC NAND is different and needs special care, otherwise UBI or UBIFS
860+
* will die soon and you will lose all your data.
861+
*/
862+
if (mtd->type == MTD_MLCNANDFLASH) {
863+
pr_err("ubi: refuse attaching mtd%d - MLC NAND is not supported\n",
864+
mtd->index);
865+
return -EINVAL;
866+
}
867+
857868
if (ubi_num == UBI_DEV_NUM_AUTO) {
858869
/* Search for an empty slot in the @ubi_devices array */
859870
for (ubi_num = 0; ubi_num < UBI_MAX_DEVICES; ubi_num++)

0 commit comments

Comments
 (0)