[MTD] OneNAND: Do not allow oob write past end of page

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Feb 9 09:59:05 EST 2007


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=52e4200a6da2d98c537b95f7c502ddadf96a6934
Commit:     52e4200a6da2d98c537b95f7c502ddadf96a6934
Parent:     5b4246f1b089746703287fdf422cf15c6d6eff05
Author:     Adrian Hunter <ext-adrian.hunter at nokia.com>
AuthorDate: Tue Feb 6 09:15:39 2007 +0900
Committer:  Kyungmin Park <kyungmin.park at samsung.com>
CommitDate: Tue Feb 6 09:15:39 2007 +0900

    [MTD] OneNAND: Do not allow oob write past end of page
    
    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 at nokia.com>
    Signed-off-by: Kyungmin Park <kyungmin.park at samsung.com>
---
 drivers/mtd/onenand/onenand_base.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 6df309b..553b24d 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -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) -



More information about the linux-mtd-cvs mailing list