[PATCH 1/4] mtd: rawnand: sm_common: restore the first ECC region offset
James Hilliard
james.hilliard1 at gmail.com
Sun Nov 8 17:29:20 PST 2026
The conversion to mtd_ooblayout_ops moved the first ECC region from bytes
8-10 to bytes 5-7. Those bytes contain the bad-block marker and the first
logical-block address, so software ECC writes can overwrite them and ECC
reads use the wrong bytes.
Derive both ECC region offsets from struct sm_oob, restoring the original
8-10 and 13-15 layout without overlapping the metadata.
Fixes: 987b913c2b7e ("mtd: nand: sm_common: switch to mtd_ooblayout_ops")
Cc: stable at vger.kernel.org
Signed-off-by: James Hilliard <james.hilliard1 at gmail.com>
---
drivers/mtd/nand/raw/sm_common.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/raw/sm_common.c b/drivers/mtd/nand/raw/sm_common.c
index e238784c8c3e..a3a3a05cc5a4 100644
--- a/drivers/mtd/nand/raw/sm_common.c
+++ b/drivers/mtd/nand/raw/sm_common.c
@@ -16,7 +16,8 @@ static int oob_sm_ooblayout_ecc(struct mtd_info *mtd, int section,
return -ERANGE;
oobregion->length = 3;
- oobregion->offset = ((section + 1) * 8) - 3;
+ oobregion->offset = section ? offsetof(struct sm_oob, ecc1) :
+ offsetof(struct sm_oob, ecc2);
return 0;
}
--
2.53.0
More information about the linux-mtd
mailing list