From patchwork Wed Sep 29 12:52:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: pwrite() to nand in raw mode fails with EINVAL Date: Wed, 29 Sep 2010 02:52:27 -0000 From: Artem Bityutskiy X-Patchwork-Id: 66065 Message-Id: <1285764747.2437.116.camel@localhost> To: mbizon@freebox.fr, Maxim Levitsky Cc: David Woodhouse , "linux-mtd@lists.infradead.org" Maxime, I've cleaned up comments, added your signed-off-by and cc stable. Is this OK? It would also be nice to get an ack from Maxim Levitsky. From: Maxime Bizon Subject: [PATCH] mtd: fix NAND pwrite in raw mode Since commit 782ce79a45b3b850b108896fcf7da26754061c8f ("cleanup the nand_do_write_ops") 'pwrite()' to a NAND device fails with '-EINVAL' which comes from: /* Don't allow multipage oob writes with offset */ if (ops->ooboffs && (ops->ooboffs + ops->ooblen > oobmaxlen)) return -EINVAL; because 'ops->ooboffs' was uninitialized. This patch fixes the issue. Artem: clean-up comment, add stable. Signed-off-by: Maxime Bizon Cc: stable Signed-off-by: Artem Bityutskiy Acked-by: Maxim Levitsky --- drivers/mtd/mtdchar.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index a825002..39dcb57 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c @@ -216,6 +216,7 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t { struct mtd_oob_ops ops; + memset(&ops, 0, sizeof (ops)); ops.mode = MTD_OOB_RAW; ops.datbuf = kbuf; ops.oobbuf = NULL; @@ -319,6 +320,7 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count { struct mtd_oob_ops ops; + memset(&ops, 0, sizeof (ops)); ops.mode = MTD_OOB_RAW; ops.datbuf = kbuf; ops.oobbuf = NULL;