Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e14feafb authored by Jason Liu's avatar Jason Liu Committed by David Woodhouse
Browse files

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: default avatarJason Liu <r64343@freescale.com>
Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 1534b8b0
Loading
Loading
Loading
Loading
+8 −1
Original line number Original line Diff line number Diff line
@@ -1782,6 +1782,13 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
	else
	else
		len = mtd->oobsize;
		len = mtd->oobsize;


	/* Do not allow read past end of page */
	if ((ops->ooboffs + readlen) > len) {
		DEBUG(MTD_DEBUG_LEVEL0, "%s: Attempt to read "
				"past end of page\n", __func__);
		return -EINVAL;
	}

	if (unlikely(ops->ooboffs >= len)) {
	if (unlikely(ops->ooboffs >= len)) {
		DEBUG(MTD_DEBUG_LEVEL0, "%s: Attempt to start read "
		DEBUG(MTD_DEBUG_LEVEL0, "%s: Attempt to start read "
					"outside oob\n", __func__);
					"outside oob\n", __func__);
@@ -2377,7 +2384,7 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
		return -EINVAL;
		return -EINVAL;
	}
	}


	/* Do not allow reads past end of device */
	/* Do not allow write past end of device */
	if (unlikely(to >= mtd->size ||
	if (unlikely(to >= mtd->size ||
		     ops->ooboffs + ops->ooblen >
		     ops->ooboffs + ops->ooblen >
			((mtd->size >> chip->page_shift) -
			((mtd->size >> chip->page_shift) -