aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/pending-5.4/411-mtd-partial_eraseblock_write.patch
diff options
context:
space:
mode:
authorJohn Thomson <git@johnthomson.fastmail.com.au>2020-08-06 07:13:54 +1000
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>2020-09-19 12:41:29 +0200
commitbf2870c1d9e162f27925e9c40eca9e0069096f3b (patch)
tree6ff4fd7999dddb1149a27b839a681800f06429d4 /target/linux/generic/pending-5.4/411-mtd-partial_eraseblock_write.patch
parent8cfb839907ad3b18decc053771d619a7fff9f99b (diff)
downloadupstream-bf2870c1d9e162f27925e9c40eca9e0069096f3b.tar.gz
upstream-bf2870c1d9e162f27925e9c40eca9e0069096f3b.tar.bz2
upstream-bf2870c1d9e162f27925e9c40eca9e0069096f3b.zip
kernel: fix mtd partition erase < parent_erasesize writes
This bug applied where mtd partition end address, or erase start address, was not cleanly divisible by parent mtd erasesize. This error would cause the bits following the end of the partition to the next erasesize block boundary to be erased, and this partition-overflow data to be written to the partition erase address (missing additional partition offset address) of the mtd (top) parent device. Fixes: FS#2428 Signed-off-by: John Thomson <git@johnthomson.fastmail.com.au> Tested-by: Tomasz Maciej Nowak <tomek_n@o2.pl> [shorten commit title, add Fixes, fix kernel 4.19 as well] Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Diffstat (limited to 'target/linux/generic/pending-5.4/411-mtd-partial_eraseblock_write.patch')
-rw-r--r--target/linux/generic/pending-5.4/411-mtd-partial_eraseblock_write.patch13
1 files changed, 6 insertions, 7 deletions
diff --git a/target/linux/generic/pending-5.4/411-mtd-partial_eraseblock_write.patch b/target/linux/generic/pending-5.4/411-mtd-partial_eraseblock_write.patch
index b46c3f5ed4..c48a144d3d 100644
--- a/target/linux/generic/pending-5.4/411-mtd-partial_eraseblock_write.patch
+++ b/target/linux/generic/pending-5.4/411-mtd-partial_eraseblock_write.patch
@@ -19,7 +19,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
/* Our partition linked list */
static LIST_HEAD(mtd_partitions);
static DEFINE_MUTEX(mtd_partitions_mutex);
-@@ -206,6 +208,53 @@ static int part_erase(struct mtd_info *m
+@@ -206,11 +208,77 @@ static int part_erase(struct mtd_info *m
{
struct mtd_part *part = mtd_to_part(mtd);
int ret;
@@ -73,10 +73,9 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
instr->addr += part->offset;
ret = part->parent->_erase(part->parent, instr);
-@@ -213,6 +262,24 @@ static int part_erase(struct mtd_info *m
+ if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
instr->fail_addr -= part->offset;
- instr->addr -= part->offset;
-
++
+ if (mtd->flags & MTD_ERASE_PARTIAL) {
+ if (partial_start) {
+ part->parent->_write(part->parent,
@@ -95,10 +94,10 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
+ kfree(erase_buf);
+ }
+
- return ret;
- }
+ instr->addr -= part->offset;
-@@ -525,19 +592,22 @@ static struct mtd_part *allocate_partiti
+ return ret;
+@@ -525,19 +593,22 @@ static struct mtd_part *allocate_partiti
remainder = do_div(tmp, wr_alignment);
if ((slave->mtd.flags & MTD_WRITEABLE) && remainder) {
/* Doesn't start on a boundary of major erase size */