From patchwork Thu May 14 08:28:42 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: oobavail size calculation error in nand_base.c Date: Wed, 13 May 2009 22:28:42 -0000 From: Jinyoung Park X-Patchwork-Id: 27202 Message-Id: <280b69ac0905140128u135f8b2aua50114faebb593e0@mail.gmail.com> To: tglx@linutronix.de Cc: linux-mtd@lists.infradead.org Hello. I found error in nand_base.c. In nand_scan_tail() function, oobavail size calculation result is wrong as follow circumstances. - Define nand_ecclayout using full oobfree array like below. .oobfree = { {2, 6}, {11, 2}, {16, 8}, {27, 2}, {32, 8}, {43, 2},{48, 8}, {59, 2} } - Using ARM EABI cross compiler when kernel compile also enable "Use the ARM EABI to compile the kernl" feature in kernel menuconfig. I using ARM EABI compiler that codesourcery release arm-2008q3-51. In this case, right oobavail size is 38 but result is too much value(e.g. 2703572308...). It's random. I think sometimes happen that after beyond oobfree array(oobfree[8]) is not 0 when ARM EABI compilation. Below codes are my modified code. Please check... Thanks. Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 3d7ed43..abb5998 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -2756,9 +2756,12 @@ int nand_scan_tail(struct mtd_info *mtd) * the out of band area */ chip->ecc.layout->oobavail = 0; - for (i = 0; chip->ecc.layout->oobfree[i].length; i++) + for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES; i++) { + if (chip->ecc.layout->oobfree[i].length == 0) + break; chip->ecc.layout->oobavail += chip->ecc.layout->oobfree[i].length; + } mtd->oobavail = chip->ecc.layout->oobavail; ______________________________________________________