diff mbox

pwrite() to nand in raw mode fails with EINVAL

Message ID 1285764747.2437.116.camel@localhost
State New, archived
Headers show

Commit Message

Artem Bityutskiy Sept. 29, 2010, 12:52 p.m. UTC
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 <mbizon@freebox.fr>
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 <mbizon@freebox.fr>
Cc: stable <stable@kernel.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
 drivers/mtd/mtdchar.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Comments

Maxime Bizon Sept. 29, 2010, 1:58 p.m. UTC | #1
On Wed, 2010-09-29 at 15:52 +0300, Artem Bityutskiy wrote:

> Maxime, I've cleaned up comments, added your signed-off-by and cc
> stable. Is this OK?

Yep

> It would also be nice to get an ack from Maxim Levitsky.

The patch fixes the problem, but I let Maxim decides if that's the
correct way to fix it.
Maxim Levitsky Oct. 21, 2010, 10:54 p.m. UTC | #2
On Wed, 2010-09-29 at 15:58 +0200, Maxime Bizon wrote:
> On Wed, 2010-09-29 at 15:52 +0300, Artem Bityutskiy wrote:
> 
> > Maxime, I've cleaned up comments, added your signed-off-by and cc
> > stable. Is this OK?
> 
> Yep
> 
> > It would also be nice to get an ack from Maxim Levitsky.
> 
> The patch fixes the problem, but I let Maxim decides if that's the
> correct way to fix it.

Very sorry for not noticing this.
I will look very carefully at this tomorrow.

Best regards,
	Maxim Levitsky
Maxim Levitsky Oct. 22, 2010, 12:09 a.m. UTC | #3
On Fri, 2010-10-22 at 00:54 +0200, Maxim Levitsky wrote:
> On Wed, 2010-09-29 at 15:58 +0200, Maxime Bizon wrote:
> > On Wed, 2010-09-29 at 15:52 +0300, Artem Bityutskiy wrote:
> > 
> > > Maxime, I've cleaned up comments, added your signed-off-by and cc
> > > stable. Is this OK?
> > 
> > Yep
> > 
> > > It would also be nice to get an ack from Maxim Levitsky.
> > 
> > The patch fixes the problem, but I let Maxim decides if that's the
> > correct way to fix it.
> 
> Very sorry for not noticing this.
> I will look very carefully at this tomorrow.
> 
> Best regards,
> 	Maxim Levitsky
> 
I don't see any reason for that patch to be wrong.
I can't test it on my xD card, because like I said before its OOB is
fake, and it probably just emulates the NAND interface.

So of course:

Acked-by: Maxim Levitsky <maximlevitsky@gmail.com>

Best regards,
	Maxim Levitsky
diff mbox

Patch

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;