Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

JFFS2: don't fail on bitflips in OOB

JFFS2 was designed without thought for OOB bitflips, it seems, but they
can occur and will be reported to JFFS2 via mtd_read_oob()[1]. We don't
want to fail on these transactions, since the data was corrected.

[1] Few drivers report bitflips for OOB-only transactions. With such
drivers, this patch should have no effect.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

authored by

Brian Norris and committed by
David Woodhouse
74d83bea 6f12f59a

+4 -4
+4 -4
fs/jffs2/wbuf.c
··· 1044 1044 ops.datbuf = NULL; 1045 1045 1046 1046 ret = mtd_read_oob(c->mtd, jeb->offset, &ops); 1047 - if (ret || ops.oobretlen != ops.ooblen) { 1047 + if ((ret && !mtd_is_bitflip(ret)) || ops.oobretlen != ops.ooblen) { 1048 1048 pr_err("cannot read OOB for EB at %08x, requested %zd bytes, read %zd bytes, error %d\n", 1049 1049 jeb->offset, ops.ooblen, ops.oobretlen, ret); 1050 - if (!ret) 1050 + if (!ret || mtd_is_bitflip(ret)) 1051 1051 ret = -EIO; 1052 1052 return ret; 1053 1053 } ··· 1086 1086 ops.datbuf = NULL; 1087 1087 1088 1088 ret = mtd_read_oob(c->mtd, jeb->offset, &ops); 1089 - if (ret || ops.oobretlen != ops.ooblen) { 1089 + if ((ret && !mtd_is_bitflip(ret)) || ops.oobretlen != ops.ooblen) { 1090 1090 pr_err("cannot read OOB for EB at %08x, requested %zd bytes, read %zd bytes, error %d\n", 1091 1091 jeb->offset, ops.ooblen, ops.oobretlen, ret); 1092 - if (!ret) 1092 + if (!ret || mtd_is_bitflip(ret)) 1093 1093 ret = -EIO; 1094 1094 return ret; 1095 1095 }