--- a/drivers/mtd/nand/nand_base.c	2009-07-07 15:40:35.000000000 +0530
+++ b/drivers/mtd/nand/nand_base.c	2009-07-07 15:40:51.000000000 +0530
@@ -1427,6 +1427,13 @@ static int nand_do_read_oob(struct mtd_i
 		return -EINVAL;
 	}

+	/* Do not allow read past end of page */
+	if ((ops->ooboffs + ops->ooblen) > len) {
+		DEBUG(MTD_DEBUG_LEVEL0, "%s: Attempt to read "
+				"past end of page\n", __func__);
+		return -EINVAL;
+	}
+
 	/* Do not allow reads past end of device */
 	if (unlikely(from >= mtd->size ||
 		     ops->ooboffs + readlen > ((mtd->size >> chip->page_shift) -
