From 83141301c75e49a3e08473fd79dea07b6fc3ce2a Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Apr 20 2023 11:00:12 +0000 Subject: mtdblock: tolerate corrected bit-flips (bsc#1012628). --- diff --git a/patches.kernel.org/6.2.12-021-mtdblock-tolerate-corrected-bit-flips.patch b/patches.kernel.org/6.2.12-021-mtdblock-tolerate-corrected-bit-flips.patch new file mode 100644 index 0000000..1184bd3 --- /dev/null +++ b/patches.kernel.org/6.2.12-021-mtdblock-tolerate-corrected-bit-flips.patch @@ -0,0 +1,64 @@ +From: Bang Li +Date: Wed, 29 Mar 2023 00:30:12 +0800 +Subject: [PATCH] mtdblock: tolerate corrected bit-flips +References: bsc#1012628 +Patch-mainline: 6.2.12 +Git-commit: 0c3089601f064d80b3838eceb711fcac04bceaad + +commit 0c3089601f064d80b3838eceb711fcac04bceaad upstream. + +mtd_read() may return -EUCLEAN in case of corrected bit-flips.This +particular condition should not be treated like an error. + +Signed-off-by: Bang Li +Fixes: e47f68587b82 ("mtd: check for max_bitflips in mtd_read_oob()") +Cc: # v3.7 +Acked-by: Richard Weinberger +Signed-off-by: Miquel Raynal +Link: https://lore.kernel.org/linux-mtd/20230328163012.4264-1-libang.linuxer@gmail.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Jiri Slaby +--- + drivers/mtd/mtdblock.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c +index 1e94e7d1..a0a1194d 100644 +--- a/drivers/mtd/mtdblock.c ++++ b/drivers/mtd/mtdblock.c +@@ -153,7 +153,7 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos, + mtdblk->cache_state = STATE_EMPTY; + ret = mtd_read(mtd, sect_start, sect_size, + &retlen, mtdblk->cache_data); +- if (ret) ++ if (ret && !mtd_is_bitflip(ret)) + return ret; + if (retlen != sect_size) + return -EIO; +@@ -188,8 +188,12 @@ static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos, + pr_debug("mtdblock: read on \"%s\" at 0x%lx, size 0x%x\n", + mtd->name, pos, len); + +- if (!sect_size) +- return mtd_read(mtd, pos, len, &retlen, buf); ++ if (!sect_size) { ++ ret = mtd_read(mtd, pos, len, &retlen, buf); ++ if (ret && !mtd_is_bitflip(ret)) ++ return ret; ++ return 0; ++ } + + while (len > 0) { + unsigned long sect_start = (pos/sect_size)*sect_size; +@@ -209,7 +213,7 @@ static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos, + memcpy (buf, mtdblk->cache_data + offset, size); + } else { + ret = mtd_read(mtd, pos, size, &retlen, buf); +- if (ret) ++ if (ret && !mtd_is_bitflip(ret)) + return ret; + if (retlen != size) + return -EIO; +-- +2.35.3 + diff --git a/series.conf b/series.conf index 1589643..623c10d 100644 --- a/series.conf +++ b/series.conf @@ -2248,6 +2248,7 @@ patches.kernel.org/6.2.12-018-btrfs-restore-the-thread_pool-behavior-in-remo.patch patches.kernel.org/6.2.12-019-btrfs-fix-fast-csum-implementation-detection.patch patches.kernel.org/6.2.12-020-fbmem-Reject-FB_ACTIVATE_KD_TEXT-from-userspac.patch + patches.kernel.org/6.2.12-021-mtdblock-tolerate-corrected-bit-flips.patch ######################################################## # Build fixes that apply to the vanilla kernel too.