From cdcf12b211d45bd68acae9d8189275d29d500d12 Mon Sep 17 00:00:00 2001 From: Jon Povey Date: Thu, 30 Sep 2010 20:41:34 +0900 Subject: 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 Signed-off-by: Artem Bityutskiy Signed-off-by: David Woodhouse --- drivers/mtd/nand/nand_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/mtd') diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 53f4e41836f..1f75a1b1f7c 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) { -- cgit v1.2.3-70-g09d2