From patchwork Tue Sep 28 18:47:30 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 From: Maxime Bizon X-Patchwork-Id: 66014 Message-Id: <1285699650.32420.70.camel@sakura.staff.proxad.net> To: Maxim Levitsky Cc: "linux-mtd@lists.infradead.org" , David.Woodhouse@intel.com Date: Tue, 28 Sep 2010 20:47:30 +0200 Hi, Since commit 782ce79a45b3b850b108896fcf7da26754061c8f ("cleanup the nand_do_write_ops"), a pwrite() to a NAND device fails with EINVAL. The EINVAL comes from here: /* Don't allow multipage oob writes with offset */ if (ops->ooboffs && (ops->ooboffs + ops->ooblen > oobmaxlen)) return -EINVAL; ops->ooboffs seems uninitialized. I think the following memset() are missing: diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index e4def84..731ff36 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c @@ -202,6 +202,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; @@ -305,6 +306,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;