aboutsummaryrefslogtreecommitdiff
path: root/drivers/mtd/inftlcore.c
diff options
context:
space:
mode:
authorTHOMSON, Adam (Adam) <adam.thomson@alcatel-lucent.com>2011-06-14 16:52:38 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2011-11-11 09:37:19 -0800
commit02376e54a976843aaa722b661123a6acc2b70b14 (patch)
tree99809a16c8bee05a4080937ac3e0358319d6b039 /drivers/mtd/inftlcore.c
parent82eaf854859022f7bf1aa9122ed533516187cbff (diff)
mtd: nand_base: always initialise oob_poi before writing OOB data
commit f722013ee9fd24623df31dec9a91a6d02c3e2f2f upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/mtd/inftlcore.c')
0 files changed, 0 insertions, 0 deletions