[PATCH 05/15] vbe: Tidy up error checking with blk_read()
Simon Glass
sjg at chromium.org
Thu Jan 9 13:30:00 CET 2025
This function can read fewer blocks than requested, so update the checks
to handle this.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
boot/vbe_common.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/boot/vbe_common.c b/boot/vbe_common.c
index dfe44822430..c7f09c6d090 100644
--- a/boot/vbe_common.c
+++ b/boot/vbe_common.c
@@ -39,6 +39,8 @@ int vbe_read_fit(struct udevice *blk, ulong area_offset, ulong area_size,
ret = blk_read(blk, blknum, 1, sbuf);
if (ret < 0)
return log_msg_ret("rd", ret);
+ else if (ret != 1)
+ return log_msg_ret("rd2", -EIO);
ret = fdt_check_header(sbuf);
if (ret < 0)
@@ -127,6 +129,8 @@ int vbe_read_fit(struct udevice *blk, ulong area_offset, ulong area_size,
blknum, full_size, num_blks, base, base_buf, ret);
if (ret < 0)
return log_msg_ret("rd", ret);
+ if (ret != num_blks)
+ return log_msg_ret("rd", -EIO);
}
if (load_addrp)
*load_addrp = load_addr;
--
2.34.1
More information about the U-Boot
mailing list