Skip to content

Commit 577b4eb

Browse files
richardweinbergergregkh
authored andcommitted
ubi: Reject MLC NAND
commit b5094b7 upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7ade852 commit 577b4eb

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
@@ -845,6 +845,17 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
845845
return -EINVAL;
846846
}
847847

848+
/*
849+
* Both UBI and UBIFS have been designed for SLC NAND and NOR flashes.
850+
* MLC NAND is different and needs special care, otherwise UBI or UBIFS
851+
* will die soon and you will lose all your data.
852+
*/
853+
if (mtd->type == MTD_MLCNANDFLASH) {
854+
pr_err("ubi: refuse attaching mtd%d - MLC NAND is not supported\n",
855+
mtd->index);
856+
return -EINVAL;
857+
}
858+
848859
if (ubi_num == UBI_DEV_NUM_AUTO) {
849860
/* Search for an empty slot in the @ubi_devices array */
850861
for (ubi_num = 0; ubi_num < UBI_MAX_DEVICES; ubi_num++)

0 commit comments

Comments
 (0)