]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
ubi: Reject MLC NAND
authorRichard Weinberger <richard@nod.at>
Sat, 3 Mar 2018 10:45:54 +0000 (11:45 +0100)
committerRichard Weinberger <richard@nod.at>
Wed, 4 Apr 2018 21:48:11 +0000 (23:48 +0200)
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>
Acked-by: Boris Brezillon <boris.brezillon@bootlin.com>
Acked-by: Artem Bityutskiy <dedekind1@gmail.com>
drivers/mtd/ubi/build.c

index e941395de3aedc0d4fc6d641e214ec9848c72e27..753494e042d51cdbfb22b93fc16c58fa43002ec0 100644 (file)
@@ -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++)