Skip to content

Commit

Permalink
[MTD] OneNAND: Do not allow oob write past end of page
Browse files Browse the repository at this point in the history
OneNAND can write oob to successive pages, but NAND
does not do that.  For compatibility, disallow OneNAND
from writing past the end of the page.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
  • Loading branch information
Adrian Hunter authored and Kyungmin Park committed Feb 6, 2007
1 parent 5b4246f commit 52e4200
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/mtd/onenand/onenand_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,13 @@ static int onenand_do_write_oob(struct mtd_info *mtd, loff_t to, size_t len,
return -EINVAL;
}

/* For compatibility with NAND: Do not allow write past end of page */
if (column + len > oobsize) {
DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_oob: "
"Attempt to write past end of page\n");
return -EINVAL;
}

/* Do not allow reads past end of device */
if (unlikely(to >= mtd->size ||
column + len > ((mtd->size >> this->page_shift) -
Expand Down

0 comments on commit 52e4200

Please sign in to comment.