From 868801e561d5d6df40a66197e2f803a109c19e7a Mon Sep 17 00:00:00 2001
From: Todd Poynor <tpoynor@mvista.com>
Date: Sat, 5 Nov 2005 03:21:15 +0000
Subject: [MTD] NAND: nand_write_ecc memory and OOB corruption

Nathan Roberts noticed the nand_write_ecc index into oobbuf goes out of
bounds when crossing an erase block boundary, causing incorrect OOB data
to be written and corrupting memory.  Reset the index to zero after
re-preparing oobbuf for a new erase block.

Signed-off-by: Todd Poynor <tpoynor@mvista.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/mtd/nand/nand_base.c | 1 +
 1 file changed, 1 insertion(+)

(limited to 'drivers')

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index c7b1ce3..c18ea76 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1722,6 +1722,7 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
 			startpage = page;
 			oobbuf = nand_prepare_oobbuf (mtd, eccbuf, oobsel, 
 					autoplace, numpages);
+			oob = 0;
 			/* Check, if we cross a chip boundary */
 			if (!page) {
 				chipnr++;
-- 
cgit v1.1