From: Artem Bityutskiy <dedekind1@gmail.com>
To: "THOMSON, Adam (Adam)" <adam.thomson@alcatel-lucent.com>
Cc: "linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>
Subject: Re: [PATCH upstream] nand: nand_base: Always initialise oob_poi before writing OOB data
Date: Wed, 22 Jun 2011 08:55:08 +0300 [thread overview]
Message-ID: <1308722112.18119.36.camel@sauron> (raw)
In-Reply-To: <E14CAA9D00C5044EACE0C59FC2A1C7F5059AACE12D@FRMRSSXCHMBSC1.dc-m.alcatel-lucent.com>
On Tue, 2011-06-14 at 16:52 +0200, THOMSON, Adam (Adam) wrote:
> In nand_do_write_ops() code it is possible for a caller to provide
> ops.oobbuf populated and ops.mode == MTD_OOB_AUTO, which currently
> means that the chip->oob_poi buffer isn't initialised to all 0xFF.
> The nand_fill_oob() method then carries out the task of copying
> the provided OOB data to oob_poi, but with MTD_OOB_AUTO it skips
> areas marked as unavailable by the layout struct, including the
> bad block marker bytes.
>
> An example of this causing issues is when the last OOB data read
> was from the start of a bad block where the markers are not 0xFF,
> and the caller wishes to write new OOB data at the beginning of
> another block. In this scenario the caller would provide OOB data,
> but nand_fill_oob() would skip the bad block marker bytes in
> oob_poi before copying the OOB data provided by the caller.
> This means that when the OOB data is written back to NAND,
> the block is inadvertently marked as bad without the caller knowing.
> This has been witnessed when using YAFFS2 where tags are stored
> in the OOB.
>
> To avoid this oob_poi is always initialised to 0xFF to make sure
> no left over data is inadvertently written back to the OOB area.
>
> Signed-off-by: Adam Thomson <adam.thomson@alcatel-lucent.com>
Added the -stable CC here and pushed to l2-mtd-2.6.git with some
modifications.
> * nand_fill_oob - [Internal] Transfer client buffer to oob
> * @chip: nand chip structure
> + * @mtd: MTD device structure
> * @oob: oob data buffer
> * @len: oob data write length
> * @ops: oob ops structure
> */
> -static uint8_t *nand_fill_oob(struct nand_chip *chip, uint8_t *oob, size_t len,
> - struct mtd_oob_ops *ops)
> +static uint8_t *nand_fill_oob(struct nand_chip *chip, struct mtd_info *mtd,
> + uint8_t *oob, size_t len, struct mtd_oob_ops *ops)
> {
Since we can get chip from mtd->prive, it is not necessary to pass both
chip and mtd to this function, it is enough to only pass mtd.
I've done this modification, the resulting patch is here:
http://git.infradead.org/users/dedekind/l2-mtd-2.6.git/commit/6a146696fdcf383d90753145dfb367e499790940
Would you please take a look and even better - give it a try?
Thanks!
--
Best Regards,
Artem Bityutskiy
next prev parent reply other threads:[~2011-06-22 5:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-14 14:52 [PATCH upstream] nand: nand_base: Always initialise oob_poi before writing OOB data THOMSON, Adam (Adam)
2011-06-22 5:55 ` Artem Bityutskiy [this message]
2011-06-22 10:41 ` THOMSON, Adam (Adam)
2011-06-22 10:57 ` Artem Bityutskiy
2011-06-22 11:08 ` THOMSON, Adam (Adam)
2011-06-22 15:40 ` THOMSON, Adam (Adam)
2011-06-23 8:22 ` Artem Bityutskiy
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=1308722112.18119.36.camel@sauron \
--to=dedekind1@gmail.com \
--cc=adam.thomson@alcatel-lucent.com \
--cc=linux-mtd@lists.infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.