* [PATCH] fastboot: Fix blk_dwrite error checking
@ 2026-05-24 19:25 Francois Berder
2026-06-08 9:27 ` Mattijs Korpershoek
0 siblings, 1 reply; 2+ messages in thread
From: Francois Berder @ 2026-05-24 19:25 UTC (permalink / raw)
To: u-boot; +Cc: Mattijs Korpershoek, Peng Fan, Tom Rini, Jaehoon Chung
blk_dwrite() returns the number of blocks written.
The code was only checking if the return value was different
than 0. Hence, partial writes were considered successful.
Fix blk_dwrite error handling by checking that all blocks
are written.
Signed-off-by: Francois Berder <fberder@outlook.fr>
---
drivers/fastboot/fb_mmc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
index 11d9c8e8460..9bc782ccd02 100644
--- a/drivers/fastboot/fb_mmc.c
+++ b/drivers/fastboot/fb_mmc.c
@@ -263,7 +263,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
/* Write new kernel size to boot image header */
hdr->kernel_size = download_bytes;
res = blk_dwrite(dev_desc, info.start, hdr_sectors, (void *)hdr);
- if (res == 0) {
+ if (res != hdr_sectors) {
pr_err("cannot writeback boot image header\n");
fastboot_fail("cannot write back boot image header", response);
return -1;
@@ -275,7 +275,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
sectors_per_page;
res = blk_dwrite(dev_desc, kernel_sector_start, kernel_sectors,
download_buffer);
- if (res == 0) {
+ if (res != kernel_sectors) {
pr_err("cannot write new kernel\n");
fastboot_fail("cannot write new kernel", response);
return -1;
@@ -287,7 +287,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
sectors_per_page;
res = blk_dwrite(dev_desc, ramdisk_sector_start, ramdisk_sectors,
ramdisk_buffer);
- if (res == 0) {
+ if (res != ramdisk_sectors) {
pr_err("cannot write back original ramdisk\n");
fastboot_fail("cannot write back original ramdisk", response);
return -1;
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fastboot: Fix blk_dwrite error checking
2026-05-24 19:25 [PATCH] fastboot: Fix blk_dwrite error checking Francois Berder
@ 2026-06-08 9:27 ` Mattijs Korpershoek
0 siblings, 0 replies; 2+ messages in thread
From: Mattijs Korpershoek @ 2026-06-08 9:27 UTC (permalink / raw)
To: Francois Berder, u-boot
Cc: Mattijs Korpershoek, Peng Fan, Tom Rini, Jaehoon Chung
Hi Francois,
Thank you for the patch.
On Sun, May 24, 2026 at 21:25, Francois Berder <fberder@outlook.fr> wrote:
> blk_dwrite() returns the number of blocks written.
> The code was only checking if the return value was different
> than 0. Hence, partial writes were considered successful.
> Fix blk_dwrite error handling by checking that all blocks
> are written.
>
> Signed-off-by: Francois Berder <fberder@outlook.fr>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
> ---
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-08 9:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-24 19:25 [PATCH] fastboot: Fix blk_dwrite error checking Francois Berder
2026-06-08 9:27 ` Mattijs Korpershoek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.