pwrite() to nand in raw mode fails with EINVAL

Maxime Bizon mbizon at freebox.fr
Tue Sep 28 14:47:30 EDT 2010


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





More information about the linux-mtd mailing list