aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJason Liu <r64343@freescale.com>2010-11-19 03:40:45 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-12-03 11:31:44 -0500
commite14feafbe0d5c6d64bb6fe4eba928cb57ac9a4c8 (patch)
tree20764c02a1ee5900e101c04d5234a992f89ca4b7 /drivers
parent1534b8b09757190ce6e97fa97f9ad77c49082cd8 (diff)
mtd: nand: add check for out of page read
When run mtd_oobtest case, there will be one error for step(4), which turned out it need add one check for out of page read in nand_do_read_oob just like mtd_do_write_oob did it already. This commit also fix one typo error for comments in mtd_do_write_oob Signed-off-by: Jason Liu <r64343@freescale.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/nand/nand_base.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 1f75a1b1f7c3..75d199e4f25b 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1782,6 +1782,13 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
1782 else 1782 else
1783 len = mtd->oobsize; 1783 len = mtd->oobsize;
1784 1784
1785 /* Do not allow read past end of page */
1786 if ((ops->ooboffs + readlen) > len) {
1787 DEBUG(MTD_DEBUG_LEVEL0, "%s: Attempt to read "
1788 "past end of page\n", __func__);
1789 return -EINVAL;
1790 }
1791
1785 if (unlikely(ops->ooboffs >= len)) { 1792 if (unlikely(ops->ooboffs >= len)) {
1786 DEBUG(MTD_DEBUG_LEVEL0, "%s: Attempt to start read " 1793 DEBUG(MTD_DEBUG_LEVEL0, "%s: Attempt to start read "
1787 "outside oob\n", __func__); 1794 "outside oob\n", __func__);
@@ -2377,7 +2384,7 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
2377 return -EINVAL; 2384 return -EINVAL;
2378 } 2385 }
2379 2386
2380 /* Do not allow reads past end of device */ 2387 /* Do not allow write past end of device */
2381 if (unlikely(to >= mtd->size || 2388 if (unlikely(to >= mtd->size ||
2382 ops->ooboffs + ops->ooblen > 2389 ops->ooboffs + ops->ooblen >
2383 ((mtd->size >> chip->page_shift) - 2390 ((mtd->size >> chip->page_shift) -