[PATCH v2 12/22] vbe: Tidy up error checking with blk_read()

Simon Glass sjg at chromium.org
Thu Jan 16 02:27:13 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>
---

(no changes since v1)

 boot/vbe_common.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/boot/vbe_common.c b/boot/vbe_common.c
index ecf4ad916e0..0f5e0e4ca98 100644
--- a/boot/vbe_common.c
+++ b/boot/vbe_common.c
@@ -126,6 +126,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)
@@ -214,6 +216,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