mtd: nand: omap2: Fix subpage write
authorRoger Quadros <rogerq@ti.com>
Fri, 20 Oct 2017 12:16:21 +0000 (15:16 +0300)
committerBoris Brezillon <boris.brezillon@free-electrons.com>
Fri, 27 Oct 2017 14:53:23 +0000 (16:53 +0200)
commit739c64414f01748a36e7d82c8e0611dea94412bd
tree92bbd573a2aae1eca85b20040e734c08e01dce23
parent1f3df4dc088d927683b292118cd8b4eaaf1af573
mtd: nand: omap2: Fix subpage write

Since v4.12, NAND subpage writes were causing a NULL pointer
dereference on OMAP platforms (omap2-nand) using OMAP_ECC_BCH4_CODE_HW,
OMAP_ECC_BCH8_CODE_HW and OMAP_ECC_BCH16_CODE_HW.

This is because for those ECC modes, omap_calculate_ecc_bch()
generates ECC bytes for the entire (multi-sector) page and this can
overflow the ECC buffer provided by nand_write_subpage_hwecc()
as it expects ecc.calculate() to return ECC bytes for just one sector.

However, the root cause of the problem is present since v3.9
but was not seen then as NAND buffers were being allocated
as one big chunk prior to commit 3deb9979c731 ("mtd: nand: allocate
aligned buffers if NAND_OWN_BUFFERS is unset").

Fix the issue by providing a OMAP optimized write_subpage()
implementation.

Fixes: 62116e5171e0 ("mtd: nand: omap2: Support for hardware BCH error correction.")
Cc: <stable@vger.kernel.org>
Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
drivers/mtd/nand/omap2.c