[MTD] OneNAND: Do not allow oob write past end of page
authorAdrian Hunter <ext-adrian.hunter@nokia.com>
Tue, 6 Feb 2007 00:15:39 +0000 (09:15 +0900)
committerKyungmin Park <kyungmin.park@samsung.com>
Tue, 6 Feb 2007 00:15:39 +0000 (09:15 +0900)
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>
drivers/mtd/onenand/onenand_base.c

index 6df309b89e9ac8f362ee789c186cd55946658f00..553b24d93335ba3279c9e5c969f5b6131668ccb1 100644 (file)
@@ -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) -