summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2022-11-23 12:39:11 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2022-11-23 12:39:13 +0100
commit52fa8e675cddf70cf381c379aa77abfaedd75417 (patch)
treea7180e26a9fff39cd859c837becfb4eb86babe4b
parentf8a72e1ecb48424da3af0e72b564ade38f86d40f (diff)
downloadbarebox-52fa8e675cddf70cf381c379aa77abfaedd75417.tar.gz
barebox-52fa8e675cddf70cf381c379aa77abfaedd75417.tar.xz
fastboot: ubiformat: Fix writing sparse images
in ubiformat_write() we may not write trailing empty areas in erase blocks as UBI assumes them to be empty and writable. This code path is used when fastboot handles sparse images. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--common/ubiformat.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/common/ubiformat.c b/common/ubiformat.c
index 1edfc5b2a3..d8399ad9d6 100644
--- a/common/ubiformat.c
+++ b/common/ubiformat.c
@@ -745,6 +745,7 @@ int ubiformat_write(struct mtd_info *mtd, const void *buf, size_t count,
while (count) {
size_t now = mtd->erasesize - offset_in_peb;
+ int new_len;
if (now > count)
now = count;
@@ -780,7 +781,8 @@ int ubiformat_write(struct mtd_info *mtd, const void *buf, size_t count,
}
}
- ret = mtd_peb_write(mtd, buf, peb, offset_in_peb, now);
+ new_len = drop_ffs(mtd, buf, now);
+ ret = mtd_peb_write(mtd, buf, peb, offset_in_peb, new_len);
if (ret < 0)
return ret;