[MTD] NAND: nand_write_ecc memory and OOB corruption
authorTodd Poynor <tpoynor@mvista.com>
Sat, 5 Nov 2005 03:21:15 +0000 (03:21 +0000)
committerThomas Gleixner <tglx@mtd.linutronix.de>
Mon, 7 Nov 2005 01:24:31 +0000 (02:24 +0100)
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

index c7b1ce38c63c5d628479edaeed4cf0e81e0f648d..c18ea76ed408b712d2e818af8ae7d67e79f9dd2d 100644 (file)
@@ -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++;