mtd: nand: sunxi: check ecc->size values
authorBoris Brezillon <boris.brezillon@free-electrons.com>
Mon, 6 Jun 2016 11:59:13 +0000 (13:59 +0200)
committerBoris Brezillon <boris.brezillon@free-electrons.com>
Mon, 11 Jul 2016 06:40:12 +0000 (08:40 +0200)
Verify that the ecc->size value is either 512 or 1024 bytes.
This should always be the case if this field was assigned to the
nand->ecc_step_size_ds value, but can be wrong when the user overloaded
this value with the nand-ecc-step-size DT property.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
drivers/mtd/nand/sunxi_nand.c

index bb440b91096f372bddd5124b4010ed8647d168e6..6e319bace72405009eb5f904838ef333946756d1 100644 (file)
@@ -1786,6 +1786,9 @@ static int sunxi_nand_hw_common_ecc_ctrl_init(struct mtd_info *mtd,
        if (!data)
                return -ENOMEM;
 
+       if (ecc->size != 512 && ecc->size != 1024)
+               return -EINVAL;
+
        /* Prefer 1k ECC chunk over 512 ones */
        if (ecc->size == 512 && mtd->writesize > 512) {
                ecc->size = 1024;
This page took 0.025539 seconds and 5 git commands to generate.