[openwrt/openwrt] ramips: fix kernel oops in `mt7621_nfc_write_page_hwecc`

LEDE Commits lede-commits at lists.infradead.org
Wed Nov 4 09:11:23 EST 2020


981213 pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/df469befdc4c13d260b99f3a1e15bc418a429020

commit df469befdc4c13d260b99f3a1e15bc418a429020
Author: Anton Ryzhov <anton at ryzhov.me>
AuthorDate: Sun Nov 1 16:06:26 2020 +0100

    ramips: fix kernel oops in `mt7621_nfc_write_page_hwecc`
    
    `mt7621_nfc_write_page_hwecc` may be called with `buf=NULL`, but
    `mt7621_nfc_check_empty_page` always tries to read it.
    That caused Oops:
    `Unable to handle kernel paging request at virtual address 00000000`
    
    Fixes: FS#3416
    Signed-off-by: Anton Ryzhov <anton at ryzhov.me>
---
 ...-mtd-rawnand-add-driver-support-for-MT7621-nand-flash.patch | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/target/linux/ramips/patches-5.4/0300-mtd-rawnand-add-driver-support-for-MT7621-nand-flash.patch b/target/linux/ramips/patches-5.4/0300-mtd-rawnand-add-driver-support-for-MT7621-nand-flash.patch
index f65092afb1..ba844fed0f 100644
--- a/target/linux/ramips/patches-5.4/0300-mtd-rawnand-add-driver-support-for-MT7621-nand-flash.patch
+++ b/target/linux/ramips/patches-5.4/0300-mtd-rawnand-add-driver-support-for-MT7621-nand-flash.patch
@@ -47,7 +47,7 @@ Signed-off-by: Weijie Gao <weijie.gao at mediatek.com>
  obj-$(CONFIG_MTD_NAND_TEGRA)		+= tegra_nand.o
 --- /dev/null
 +++ b/drivers/mtd/nand/raw/mt7621_nand.c
-@@ -0,0 +1,1348 @@
+@@ -0,0 +1,1350 @@
 +// SPDX-License-Identifier: GPL-2.0
 +/*
 + * MediaTek MT7621 NAND Flash Controller driver
@@ -1155,9 +1155,11 @@ Signed-off-by: Weijie Gao <weijie.gao at mediatek.com>
 +	uint32_t i, j;
 +	u8 *oobptr;
 +
-+	for (i = 0; i < mtd->writesize; i++)
-+		if (buf[i] != 0xff)
-+			return 0;
++	if (buf) {
++		for (i = 0; i < mtd->writesize; i++)
++			if (buf[i] != 0xff)
++				return 0;
++	}
 +
 +	for (i = 0; i < nand->ecc.steps; i++) {
 +		oobptr = oob_fdm_ptr(nand, i);



More information about the lede-commits mailing list