From: David Woodhouse <dwmw2@infradead.org>
To: mbizon@freebox.fr
Cc: "linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
Maxim Levitsky <maximlevitsky@gmail.com>
Subject: Re: pwrite() to nand in raw mode fails with EINVAL
Date: Thu, 30 Sep 2010 11:48:25 +0900 [thread overview]
Message-ID: <1285814905.31224.4.camel@macbook.infradead.org> (raw)
In-Reply-To: <1285699650.32420.70.camel@sakura.staff.proxad.net>
On Tue, 2010-09-28 at 20:47 +0200, Maxime Bizon wrote:
> 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:
Alternatively, perhaps the sanity check should treat the ->oob{offs,len}
fields as undefined if ->oobbuf is NULL (which is set explicitly in the
two functions you patched). Otherwise, we've effectively changed the API
and we need to make more of an effort to audit *all* users.
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index d551ddd..5d0dc74 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2200,7 +2200,8 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
memset(chip->oob_poi, 0xff, mtd->oobsize);
/* Don't allow multipage oob writes with offset */
- if (ops->ooboffs && (ops->ooboffs + ops->ooblen > oobmaxlen))
+ if (ops->oobbuf && ops->ooboffs &&
+ (ops->ooboffs + ops->ooblen > oobmaxlen))
return -EINVAL;
while(1) {
--
David Woodhouse Open Source Technology Centre
David.Woodhouse@intel.com Intel Corporation
prev parent reply other threads:[~2010-09-30 2:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1285814905.31224.4.camel@macbook.infradead.org \
--to=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=maximlevitsky@gmail.com \
--cc=mbizon@freebox.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).