aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorBoris Brezillon <boris.brezillon@free-electrons.com>2016-06-06 07:59:13 -0400
committerBoris Brezillon <boris.brezillon@free-electrons.com>2016-07-11 02:40:12 -0400
commita92c721dc638b3745266ffe85617fe54dfadff19 (patch)
treea86c3be8470dff254e9a028cd73a51934e25abb4 /drivers/mtd
parent872164e41fc8dee154e5f5d22580b34e198eed69 (diff)
mtd: nand: sunxi: check ecc->size values
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>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/nand/sunxi_nand.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
index bb440b91096f..6e319bace724 100644
--- a/drivers/mtd/nand/sunxi_nand.c
+++ b/drivers/mtd/nand/sunxi_nand.c
@@ -1786,6 +1786,9 @@ static int sunxi_nand_hw_common_ecc_ctrl_init(struct mtd_info *mtd,
1786 if (!data) 1786 if (!data)
1787 return -ENOMEM; 1787 return -ENOMEM;
1788 1788
1789 if (ecc->size != 512 && ecc->size != 1024)
1790 return -EINVAL;
1791
1789 /* Prefer 1k ECC chunk over 512 ones */ 1792 /* Prefer 1k ECC chunk over 512 ones */
1790 if (ecc->size == 512 && mtd->writesize > 512) { 1793 if (ecc->size == 512 && mtd->writesize > 512) {
1791 ecc->size = 1024; 1794 ecc->size = 1024;