linux/drivers/mtd
THOMSON, Adam (Adam) f722013ee9 mtd: nand_base: always initialise oob_poi before writing OOB data
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.

Credits to Brian Norris <computersforpeace@gmail.com> for fixing this
patch.

Signed-off-by: Adam Thomson <adam.thomson@alcatel-lucent.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
Cc: stable@kernel.org [2.6.20+]
2011-09-11 15:02:10 +03:00
..
chips mtd: remove duplicate assignment of chip->state 2011-05-25 02:11:13 +01:00
devices mtd: mtd_dataflash.c: use mtd_device_parse_register 2011-09-11 15:02:10 +03:00
lpddr mtd: remove duplicate assignment of chip->state 2011-05-25 02:11:13 +01:00
maps mtd: edb7312: correctly pass MTD name to parsers 2011-09-11 15:02:10 +03:00
nand mtd: nand_base: always initialise oob_poi before writing OOB data 2011-09-11 15:02:10 +03:00
onenand mtd: onenand: remove redundant mtd_device_unregister before onenand_release 2011-09-11 15:02:10 +03:00
tests mtd: speedtest: fix integer overflow 2011-03-11 14:22:49 +00:00
ubi Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6 2011-07-22 19:02:39 -07:00
Kconfig Merge git://git.infradead.org/mtd-2.6 2011-05-27 20:06:53 -07:00
Makefile mtd: kill CONFIG_MTD_PARTITIONS 2011-05-25 02:25:35 +01:00
afs.c mtd: Update copyright notices 2010-08-08 20:58:20 +01:00
ar7part.c
cmdlinepart.c mtd: remove printk's for [kv][mz]alloc failures 2011-09-11 15:02:05 +03:00
ftl.c Update broken web addresses in the kernel. 2010-10-18 11:03:14 +02:00
inftlcore.c mtd: remove printk's for [kv][mz]alloc failures 2011-09-11 15:02:05 +03:00
inftlmount.c mtd: Remove obsolete <mtd/compatmac.h> include 2010-08-08 21:19:42 +01:00
mtd_blkdevs.c mtd: mtd_blkdevs: fix error path in blktrans_open 2011-05-25 01:53:45 +01:00
mtdblock.c mtd: mtdblock: Use DEFINE_MUTEX() for mtdblks_lock 2011-09-11 15:01:59 +03:00
mtdblock_ro.c mtd: Update copyright notices 2010-08-08 20:58:20 +01:00
mtdchar.c mtd: mtdchar: add missing initializer on raw write 2011-09-11 15:02:04 +03:00
mtdconcat.c mtd: mtdconcat: fix NAND OOB write 2011-05-25 01:54:50 +01:00
mtdcore.c mtd: add new API for handling MTD registration 2011-09-11 15:02:05 +03:00
mtdcore.h mtd: remove add_mtd_partitions, add_mtd_device and friends 2011-05-25 02:25:16 +01:00
mtdoops.c Merge git://git.infradead.org/mtd-2.6 2011-01-17 11:15:30 -08:00
mtdpart.c mtd: document parse_mtd_partitions 2011-09-11 15:02:05 +03:00
mtdsuper.c convert get_sb_mtd() users to ->mount() 2010-10-29 04:16:26 -04:00
mtdswap.c mtd: convert vmalloc/memset to vzalloc 2011-08-15 13:26:37 +03:00
nftlcore.c mtd: remove printk's for [kv][mz]alloc failures 2011-09-11 15:02:05 +03:00
nftlmount.c mtd: Update copyright notices 2010-08-08 20:58:20 +01:00
ofpart.c mtd: Fix endianness issues from device tree 2010-10-25 00:55:56 +01:00
redboot.c mtd: Update copyright notices 2010-08-08 20:58:20 +01:00
rfd_ftl.c mtd: Update copyright notices 2010-08-08 20:58:20 +01:00
sm_ftl.c Fix common misspellings 2011-03-31 11:26:23 -03:00
sm_ftl.h mtd: sm_ftl: cosmetic, use bool when possible 2010-10-25 01:33:08 +01:00
ssfdc.c mtd: remove printk's for [kv][mz]alloc failures 2011-09-11 15:02:05 +03:00