From: Adrian Hunter Date: Tue, 6 Feb 2007 00:15:39 +0000 (+0900) Subject: [MTD] OneNAND: Do not allow oob write past end of page X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=52e4200a6da2d98c537b95f7c502ddadf96a6934;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git [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 Signed-off-by: Kyungmin Park --- diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c index 6df309b89e9a..553b24d93335 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) -