diff options
author | Richard Weinberger <richard@nod.at> | 2018-03-03 13:45:54 +0300 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2018-10-21 10:45:13 +0300 |
commit | 898f78e0d5c45346e64a2e75e3631f91313dbbef (patch) | |
tree | 35eb157fa7ddcb426b7f0e24c1487cd20fe6879e | |
parent | 389751407708d34f91b43869a6f37fa8a70c2d5e (diff) | |
download | linux-898f78e0d5c45346e64a2e75e3631f91313dbbef.tar.xz |
ubi: Reject MLC NAND
commit b5094b7f135be34630e3ea8a98fa215715d0f29d 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.
Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Boris Brezillon <boris.brezillon@bootlin.com>
Acked-by: Artem Bityutskiy <dedekind1@gmail.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | drivers/mtd/ubi/build.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index c3db383a9000..7bbd11e25f23 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -905,6 +905,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++) |