linux/drivers/mtd/nand
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
..
alauda.c mtd: convert remaining users to mtd_device_register() 2011-05-25 02:25:00 +01:00
ams-delta.c mtd: convert remaining users to mtd_device_register() 2011-05-25 02:25:00 +01:00
atmel_nand.c mtd: atmel_nand.c: use mtd_device_parse_register 2011-09-11 15:02:08 +03:00
atmel_nand_ecc.h
au1550nd.c Merge git://git.infradead.org/mtd-2.6 2011-05-27 20:06:53 -07:00
autcpu12.c mtd: nand: rename NAND_USE_FLASH_BBT 2011-09-11 15:01:56 +03:00
bcm_umi_bch.c
bcm_umi_nand.c mtd: bcm_umi_nand.c: use mtd_device_parse_register 2011-09-11 15:02:08 +03:00
bf5xx_nand.c mtd: bf5xx_nand: convert to mtd_device_register() 2011-05-25 02:23:15 +01:00
cafe_nand.c mtd: cafe_nand.c: use mtd_device_parse_register 2011-09-11 15:02:08 +03:00
cmx270_nand.c mtd: cmx270_nand.c: use mtd_device_parse_register 2011-09-11 15:02:08 +03:00
cs553x_nand.c mtd: cs553x_nand.c: use mtd_device_parse_register 2011-09-11 15:02:08 +03:00
davinci_nand.c mtd: davinci_nand.c: use mtd_device_parse_register 2011-09-11 15:02:08 +03:00
denali.c mtd: denali: detect the number of banks before resetting NAND 2011-09-11 15:02:04 +03:00
denali.h mtd: denali: detect the number of banks 2011-05-25 02:02:12 +01:00
diskonchip.c mtd: nand: rename NAND_USE_FLASH_BBT 2011-09-11 15:01:56 +03:00
edb7312.c mtd: edb7312.c: use mtd_device_parse_register 2011-09-11 15:02:08 +03:00
fsl_elbc_nand.c mtd: nand: rename NAND_USE_FLASH_BBT 2011-09-11 15:01:56 +03:00
fsl_upm.c mtd: fsl_upm don't specify default parsing options 2011-09-11 15:02:01 +03:00
fsmc_nand.c mtd: fsmc_nand.c: use mtd_device_parse_register 2011-09-11 15:02:08 +03:00
gpio.c mtd: convert remaining users to mtd_device_register() 2011-05-25 02:25:00 +01:00
h1910.c mtd: h1910.c: use mtd_device_parse_register 2011-09-11 15:02:08 +03:00
jz4740_nand.c mtd: jz4740_nand.c: use mtd_device_parse_register 2011-09-11 15:02:08 +03:00
Kconfig mtd: kill CONFIG_MTD_PARTITIONS 2011-05-25 02:25:35 +01:00
Makefile mtd: nand: add software BCH ECC support 2011-03-11 17:49:08 +00:00
mpc5121_nfc.c mtd: mpc5121_nfc don't specify default parsing options 2011-09-11 15:02:02 +03:00
mxc_nand.c mtd: mxc_nand.c: use mtd_device_parse_register 2011-09-11 15:02:09 +03:00
nand_base.c mtd: nand_base: always initialise oob_poi before writing OOB data 2011-09-11 15:02:10 +03:00
nand_bbt.c mtd: remove printk's for [kv][mz]alloc failures 2011-09-11 15:02:05 +03:00
nand_bch.c mtd: nand: add software BCH ECC support 2011-03-11 17:49:08 +00:00
nand_bcm_umi.c
nand_bcm_umi.h mtd: nand_bcm: fix hot spin and code duplication 2010-02-26 16:56:35 +00:00
nand_ecc.c Merge git://git.infradead.org/mtd-2.6 2009-12-16 10:23:43 -08:00
nand_ids.c mtd: nand: support new Toshiba SLC 2010-10-24 23:38:30 +01:00
nandsim.c mtd: nand: rename NAND_USE_FLASH_BBT 2011-09-11 15:01:56 +03:00
ndfc.c mtd: ndfc: fix a memory leak in ndfc_remove 2011-09-11 15:02:05 +03:00
nomadik_nand.c mtd: nomadik_nand: add missing nand_release in nomadik_nand_remove 2011-09-11 15:01:59 +03:00
nuc900_nand.c mtd: nuc900_nand: add missing nand_release in nuc900_nand_remove 2011-09-11 15:01:58 +03:00
omap2.c mtd: omap2.c: use mtd_device_parse_register 2011-09-11 15:02:09 +03:00
orion_nand.c mtd: orion_nand.c: use mtd_device_parse_register 2011-09-11 15:02:09 +03:00
pasemi_nand.c mtd: nand: rename NAND_USE_FLASH_BBT 2011-09-11 15:01:56 +03:00
plat_nand.c mtd: plat_nand.c: use mtd_device_parse_register 2011-09-11 15:02:09 +03:00
ppchameleonevb.c mtd: ppchameleonevb.c: use mtd_device_parse_register 2011-09-11 15:02:09 +03:00
pxa3xx_nand.c mtd: pxa3xx_nand.c: use mtd_device_parse_register 2011-09-11 15:02:09 +03:00
r852.c Fix common misspellings 2011-03-31 11:26:23 -03:00
r852.h mtd: r852: remove useless pci powerup/down from suspend/resume routines 2010-10-25 01:32:21 +01:00
rtc_from4.c mtd: remove printk's for [kv][mz]alloc failures 2011-09-11 15:02:05 +03:00
s3c2410.c mtd: s3c2410.c: use mtd_device_parse_register 2011-09-11 15:02:09 +03:00
sh_flctl.c mtd: convert remaining users to mtd_device_register() 2011-05-25 02:25:00 +01:00
sharpsl.c mtd: sharpsl.c: use mtd_device_parse_register 2011-09-11 15:02:09 +03:00
sm_common.c mtd: convert remaining users to mtd_device_register() 2011-05-25 02:25:00 +01:00
sm_common.h mtd: sm_common: split smartmedia and xD table 2010-05-14 01:03:46 +01:00
socrates_nand.c mtd: socrates_nand don't specify default parsing options 2011-09-11 15:02:03 +03:00
spia.c mtd: convert remaining users to mtd_device_register() 2011-05-25 02:25:00 +01:00
tmio_nand.c mtd: tmio_nand.c: use mtd_device_parse_register 2011-09-11 15:02:09 +03:00
txx9ndfmc.c mtd: txx9ndfmc.c: use mtd_device_parse_register 2011-09-11 15:02:09 +03:00