mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Cc: Johannes Zink <jzi@pengutronix.de>
Subject: [PATCH 2/2] fastboot: ubiformat: Fix writing sparse images
Date: Wed, 23 Nov 2022 12:42:45 +0100	[thread overview]
Message-ID: <20221123114245.3258194-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20221123114245.3258194-1-s.hauer@pengutronix.de>

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>
---
 common/ubiformat.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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;
 
-- 
2.30.2




  reply	other threads:[~2022-11-23 11:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23 11:42 [PATCH 1/2] mtd: peb: return success for reading/writing 0 bytes Sascha Hauer
2022-11-23 11:42 ` Sascha Hauer [this message]
2022-12-08 14:12 ` Johannes Zink

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221123114245.3258194-2-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=jzi@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox