2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-21 19:53:59 +08:00
linux-next/drivers/mtd/nand
Hector Palacios 144f4c9839 mtd: nand: fix bug writing 1 byte less than page size
nand_do_write_ops() determines if it is writing a partial page with the
formula:
	part_pagewr = (column || writelen < (mtd->writesize - 1))

When 'writelen' is exactly 1 byte less than the NAND page size the formula
equates to zero, so the code doesn't process it as a partial write,
although it should.
As a consequence the function remains in the while(1) loop with 'writelen'
becoming 0xffffffff and iterating endlessly.

The bug may not be easy to reproduce in Linux since user space tools
usually force the padding or round-up the write size to a page-size
multiple.
This was discovered in U-Boot where the issue can be reproduced by
writing any size that is 1 byte less than a page-size multiple.
For example, on a NAND with 2K page (0x800):
	=> nand erase.part <partition>
	=> nand write $loadaddr <partition> 7ff

[Editor's note: the bug was added in commit 29072b9607, but moved
around in commit 66507c7bc8 ("mtd: nand: Add support to use nand_base
poi databuf as bounce buffer")]

Fixes: 29072b9607 ("[MTD] NAND: add subpage write support")
Signed-off-by: Hector Palacios <hector.palacios@digi.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2016-07-19 12:54:14 -07:00
..
bcm47xxnflash mtd: nand: make use of nand_set/get_controller_data() helpers 2016-01-07 10:23:41 -08:00
brcmnand mtd: nand: brcmnand: Change BUG_ON in brcmnand_send_cmd 2016-07-16 20:40:16 -07:00
gpmi-nand gpmi-nand: Handle ECC Errors in erased pages 2016-05-05 23:55:15 +02:00
ams-delta.c mtd: nand: ams-delta: set ECC algorithm explicitly 2016-04-19 22:05:31 +02:00
atmel_nand_ecc.h mtd: atmel_nand: Support 32-bit ECC strength 2016-02-12 10:27:48 -08:00
atmel_nand_nfc.h Revert "mtd: atmel_nand: Support variable RB_EDGE interrupts" 2016-05-25 20:06:28 -07:00
atmel_nand.c Revert "mtd: atmel_nand: Support variable RB_EDGE interrupts" 2016-05-25 20:06:28 -07:00
au1550nd.c mtd: nand: au1550nd: set ECC algorithm explicitly 2016-05-05 23:51:53 +02:00
bf5xx_nand.c mtd: nand: bf5xx: set ECC algorithm explicitly 2016-05-05 23:52:02 +02:00
cafe_nand.c mtd: nand: cafe: switch to mtd_ooblayout_ops 2016-05-05 23:51:39 +02:00
cmx270_nand.c mtd: nand: cmx270: set ECC algorithm explicitly 2016-05-05 23:51:54 +02:00
cs553x_nand.c mtd: nand: remove useless mtd->priv = chip assignments 2015-12-18 13:21:40 -08:00
davinci_nand.c mtd: nand: davinci: set ECC algorithm explicitly 2016-05-05 23:52:02 +02:00
denali_dt.c mtd: nand: drop owner assignment from platform_drivers 2014-10-20 16:20:58 +02:00
denali_pci.c mtd: denali_pci: switch to dev_err() 2015-08-18 17:21:37 -07:00
denali.c mtd: nand: denali: switch to mtd_ooblayout_ops 2016-05-05 23:51:40 +02:00
denali.h mtd: nand: denali: use the mtd instance embedded in struct nand_chip 2015-12-18 13:13:50 -08:00
diskonchip.c mtd: nand: diskonchip: switch to mtd_ooblayout_ops 2016-05-05 23:51:40 +02:00
docg4.c mtd: nand: docg4: switch to mtd_ooblayout_ops 2016-05-05 23:51:41 +02:00
fsl_elbc_nand.c mtd: nand: fsl_elbc: set ECC algorithm explicitly 2016-05-05 23:51:55 +02:00
fsl_ifc_nand.c mtd: nand: fsl_ifc: set ECC algorithm explicitly 2016-05-05 23:51:55 +02:00
fsl_upm.c mtd: nand: fsl_upm: set ECC algorithm explicitly 2016-05-05 23:51:54 +02:00
fsmc_nand.c mtd: mtd: drop NAND_ECC_SOFT_BCH enum value 2016-05-05 23:55:13 +02:00
gpio.c mtd: nand: gpio: set ECC algorithm explicitly 2016-04-19 22:05:31 +02:00
hisi504_nand.c mtd: nand: hisi504: rely on generic DT parsing done in nand_scan_ident() 2016-05-05 23:51:58 +02:00
jz4740_nand.c mtd: nand: jz4740: Remove unused local variable 2016-05-05 23:51:56 +02:00
jz4780_bch.c mtd: nand: jz4780: Update MODULE_AUTHOR email address 2016-07-11 08:40:19 +02:00
jz4780_bch.h mtd: nand: jz4780: driver for NAND devices on JZ4780 SoCs 2016-01-07 09:35:11 -08:00
jz4780_nand.c mtd: nand: jz4780: Update MODULE_AUTHOR email address 2016-07-11 08:40:19 +02:00
Kconfig This pull request contains only one notable change: 2016-07-15 17:06:26 -07:00
lpc32xx_mlc.c mtd: nand: lpc32xx: switch to mtd_ooblayout_ops 2016-05-05 23:51:45 +02:00
lpc32xx_slc.c mtd: nand: lpc32xx: rely on generic DT parsing done in nand_scan_ident() 2016-05-05 23:51:58 +02:00
Makefile mtd: mediatek: driver for MTK Smart Device 2016-07-11 08:39:54 +02:00
mpc5121_nfc.c mtd: nand: mpc5121_nfc: set ECC algorithm explicitly 2016-05-05 23:51:53 +02:00
mtk_ecc.c mtd: mediatek: driver for MTK Smart Device 2016-07-11 08:39:54 +02:00
mtk_ecc.h mtd: mediatek: driver for MTK Smart Device 2016-07-11 08:39:54 +02:00
mtk_nand.c mtd: mediatek: driver for MTK Smart Device 2016-07-11 08:39:54 +02:00
mxc_nand.c mtd: mtd: drop NAND_ECC_SOFT_BCH enum value 2016-05-05 23:55:13 +02:00
nand_base.c mtd: nand: fix bug writing 1 byte less than page size 2016-07-19 12:54:14 -07:00
nand_bbt.c mtd: nand: remove EXPORT_SYMBOL of nand_scan_bbt() 2016-01-23 14:00:14 -08:00
nand_bch.c mtd: nand_bch: fix spelling of "probably" 2016-05-06 09:45:45 -07:00
nand_ecc.c mtd: nand: return consistent error codes in ecc.correct() implementations 2016-01-06 18:45:46 -08:00
nand_ids.c mtd: nand: add ESMT manufacturer 2016-06-09 21:23:20 +02:00
nand_timings.c mtd: nand: Use ULL-suffix for big u64 constant 2014-08-19 11:53:09 -07:00
nandsim.c MTD updates for v4.7: 2016-05-24 11:00:20 -07:00
ndfc.c mtd: nand: make use of nand_set/get_controller_data() helpers 2016-01-07 10:23:41 -08:00
nuc900_nand.c mtd: nand: nuc900: set ECC algorithm explicitly 2016-04-19 22:05:32 +02:00
omap2.c mtd: nand: omap2: fix return value check in omap_nand_probe() 2016-07-15 17:10:46 -07:00
omap_elm.c mtd: omap_elm: print interrupt resource using %pr 2015-12-18 10:16:17 -08:00
orion_nand.c mtd: nand: orion: set ECC algorithm explicitly 2016-04-19 22:05:33 +02:00
pasemi_nand.c mtd: nand: pasemi: switch to dev_* printing functions 2016-04-19 22:05:35 +02:00
plat_nand.c mtd: nand: plat: set ECC algorithm explicitly 2016-04-19 22:05:34 +02:00
pxa3xx_nand.c mtd: nand: pxa3xx: switch to mtd_ooblayout_ops 2016-05-05 23:51:46 +02:00
qcom_nandc.c mtd: nand: qcom: switch to mtd_ooblayout_ops 2016-05-05 23:51:49 +02:00
r852.c mtd: nand: make use of nand_set/get_controller_data() helpers 2016-01-07 10:23:41 -08:00
r852.h mtd: nand: r852: use the mtd instance embedded in struct nand_chip 2015-12-18 10:54:41 -08:00
s3c2410.c mtd: nand: s3c2410: set ECC algorithm explicitly 2016-05-05 23:51:52 +02:00
sh_flctl.c mtd: nand: sh_flctl: rely on generic DT parsing done in nand_scan_ident() 2016-05-05 23:51:59 +02:00
sharpsl.c mtd: nand: sharpsl: switch to mtd_ooblayout_ops 2016-05-05 23:51:36 +02:00
sm_common.c mtd: nand: sm_common: switch to mtd_ooblayout_ops 2016-05-05 23:51:48 +02:00
sm_common.h mtd: use __packed shorthand 2014-08-19 11:53:08 -07:00
socrates_nand.c mtd: nand: socrates: set ECC algorithm explicitly 2016-04-19 22:05:35 +02:00
sunxi_nand.c mtd: nand: sunxi: prevent a small memory leak 2016-07-11 08:40:18 +02:00
tmio_nand.c mtd: nand: remove useless mtd->priv = chip assignments 2015-12-18 13:21:40 -08:00
txx9ndfmc.c mtd: nand: make use of nand_set/get_controller_data() helpers 2016-01-07 10:23:41 -08:00
vf610_nfc.c mtd: nand: vf610: switch to mtd_ooblayout_ops 2016-05-05 23:51:48 +02:00
xway_nand.c mtd: nand: xway: add nandaddr to own struct 2016-07-11 08:40:17 +02:00