mtd: nand: fix MTD_MODE_RAW writes

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sun Oct 24 20:59:12 EDT 2010


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=cdcf12b211d45bd68acae9d8189275d29d500d12
Commit:     cdcf12b211d45bd68acae9d8189275d29d500d12
Parent:     04aadf36de625647c72ec24c7e901896dd2a99e6
Author:     Jon Povey <jon.povey at racelogic.co.uk>
AuthorDate: Thu Sep 30 20:41:34 2010 +0900
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Mon Oct 25 01:33:37 2010 +0100

    mtd: nand: fix MTD_MODE_RAW writes
    
    RAW writes were broken by 782ce79a45b3b850b108896fcf7da26754061c8f
    which introduced a check of ops->ooboffs in nand_do_write_ops().
    
    When writing in RAW mode this is called with an ops struct on the stack
    of mtdchar.c:mtd_write() which does not initialise ops->ooboffs, so it
    is garbage and fails this test.
    
    This test does not make sense if ops->oobbuf is NULL, which it is in the
    RAW write path, so include that in the test.
    
    Signed-off-by: Jon Povey <jon.povey at racelogic.co.uk>
    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/nand/nand_base.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 53f4e41..1f75a1b 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2214,7 +2214,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
 		memset(chip->oob_poi, 0xff, mtd->oobsize);
 
 	/* Don't allow multipage oob writes with offset */
-	if (ops->ooboffs && (ops->ooboffs + ops->ooblen > oobmaxlen))
+	if (oob && ops->ooboffs && (ops->ooboffs + ops->ooblen > oobmaxlen))
 		return -EINVAL;
 
 	while (1) {



More information about the linux-mtd-cvs mailing list