linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* pwrite() to nand in raw mode fails with EINVAL
@ 2010-09-28 18:47 Maxime Bizon
  2010-09-29 12:44 ` Artem Bityutskiy
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Maxime Bizon @ 2010-09-28 18:47 UTC (permalink / raw)
  To: Maxim Levitsky; +Cc: linux-mtd@lists.infradead.org, David.Woodhouse


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;



-- 
Maxime

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-10-22  0:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-28 18:47 pwrite() to nand in raw mode fails with EINVAL Maxime Bizon
2010-09-29 12:44 ` Artem Bityutskiy
2010-09-29 12:52 ` Artem Bityutskiy
2010-09-29 13:58   ` Maxime Bizon
2010-10-21 22:54     ` Maxim Levitsky
2010-10-22  0:09       ` Maxim Levitsky
2010-09-30  2:48 ` David Woodhouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).