nand: add a error handler in aml_nand_add_partition
authorYi Zeng <yi.zeng@amlogic.com>
Wed, 13 Dec 2017 07:55:43 +0000 (15:55 +0800)
committerYi Zeng <yi.zeng@amlogic.com>
Mon, 18 Dec 2017 01:17:49 +0000 (18:17 -0700)
PD#156335: nand: add a error handler in aml_nand_add_partition

add a error handler in aml_nand_add_partition to avoid the endless
loop, when dts config a over size partition.

Change-Id: I8375990283bc6b36a09e09a37d041ebd929990d6
Signed-off-by: Yi Zeng <yi.zeng@amlogic.com>
arch/arm64/boot/dts/amlogic/gxl_p401_2g.dts
drivers/amlogic/mtd/aml_nand.c
drivers/amlogic/mtd/mtd_driver.c

index ef472f2..f8d85f0 100644 (file)
                        };
                        system{
                                offset=<0x0 0x0>;
-                               size=<0x0 0xDC40000>;
+                               size=<0x0 0xDC00000>;
                        };
                        data{
                                offset=<0xffffffff 0xffffffff>;
index 1ddc666..04e697a 100644 (file)
@@ -434,6 +434,12 @@ static int aml_nand_add_partition(struct aml_nand_chip *aml_chip)
                                start_blk = 0;
        do {
                offset = adjust_offset + start_blk * mtd->erasesize;
+               if (offset > mtd->size) {
+                       pr_info("%s %d error : over the nand size!!!\n",
+                       __func__, __LINE__);
+                       WARN_ON(1);
+                       return -ENOMEM;
+               }
                error = mtd->_block_isbad(mtd, offset);
                if (error == FACTORY_BAD_BLOCK_ERROR) {
                        pr_info("%s:%d factory bad addr=%llx\n",
index d7373bc..db5a737 100644 (file)
@@ -259,7 +259,8 @@ static int mtd_nand_probe(struct platform_device *pdev)
        /*prase dtb and get device(part) information*/
        prase_get_dtb_nand_parameter(aml_nand_dev, pdev);
 
-       nand_init(pdev);
+       err = nand_init(pdev);
+       pr_info("%s %d , err = %d\n", __func__, __LINE__, err);
 
 exit_error:
        return err;