public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andreas Dannenberg <dannenberg@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/7] spl: ymodem: Fix FIT loading termination handling
Date: Thu, 15 Aug 2019 15:55:26 -0500	[thread overview]
Message-ID: <20190815205532.16545-2-dannenberg@ti.com> (raw)
In-Reply-To: <20190815205532.16545-1-dannenberg@ti.com>

During FIT reading through ymodem_read_fit() the function
xyzModem_stream_read() is being used which returns zero once the end
of a stream has been reached. This could lead to an premature exit from
ymodem_read_fit() with certain-sized FIT images reporting that zero
bytes overall were read. Such a premature exit would then result in an
-EIO failure being triggered within the spl_load_simple_fit() caller
function and ultimately lead to a boot failure.

Fix this logic by simply aborting the stream read loops and continuing
with the regular code flow which ultimately would lead to returning
the number of bytes to be read ('size') as expected by the callers of
ymodem_read_fit().

Fixes: fa715193c083 ("spl: Add an option to load a FIT containing U-Boot from UART")
Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
---
 common/spl/spl_ymodem.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/common/spl/spl_ymodem.c b/common/spl/spl_ymodem.c
index 20f4260062..8ad580d8ae 100644
--- a/common/spl/spl_ymodem.c
+++ b/common/spl/spl_ymodem.c
@@ -44,7 +44,8 @@ static ulong ymodem_read_fit(struct spl_load_info *load, ulong offset,
 	while (info->image_read < offset) {
 		res = xyzModem_stream_read(buf, BUF_SIZE, &err);
 		if (res <= 0)
-			return res;
+			break;
+
 		info->image_read += res;
 	}
 
@@ -57,7 +58,7 @@ static ulong ymodem_read_fit(struct spl_load_info *load, ulong offset,
 	while (info->image_read < offset + size) {
 		res = xyzModem_stream_read(buf, BUF_SIZE, &err);
 		if (res <= 0)
-			return res;
+			break;
 
 		memcpy(addr, buf, res);
 		info->image_read += res;
-- 
2.17.1

  reply	other threads:[~2019-08-15 20:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-15 20:55 [U-Boot] [PATCH 0/7] Implement UART-based boot of TI K3 AM65x SoCs Andreas Dannenberg
2019-08-15 20:55 ` Andreas Dannenberg [this message]
2019-10-12 20:23   ` [U-Boot] [PATCH 1/7] spl: ymodem: Fix FIT loading termination handling Tom Rini
2019-08-15 20:55 ` [U-Boot] [PATCH 2/7] spl: ymodem: Make SPL Y-Modem loader framework accessible Andreas Dannenberg
2019-10-12 20:23   ` Tom Rini
2019-08-15 20:55 ` [U-Boot] [PATCH 3/7] arm: K3: common: Allow for early console functionality Andreas Dannenberg
2019-10-12 20:23   ` Tom Rini
2019-08-15 20:55 ` [U-Boot] [PATCH 4/7] arm: K3: sysfw-loader: Allow loading SYSFW via Y-Modem Andreas Dannenberg
2019-10-12 20:23   ` Tom Rini
2019-08-15 20:55 ` [U-Boot] [PATCH 5/7] armv7R: dts: k3: am654: Add MCU_UART0 related definitions Andreas Dannenberg
2019-10-12 20:24   ` Tom Rini
2019-08-15 20:55 ` [U-Boot] [PATCH 6/7] configs: am65x_evm_r5: Activate early console functionality Andreas Dannenberg
2019-10-12 20:24   ` Tom Rini
2019-08-15 20:55 ` [U-Boot] [PATCH 7/7] board: ti: am65x: Add UART boot procedure in README Andreas Dannenberg
2019-10-12 20:24   ` Tom Rini

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=20190815205532.16545-2-dannenberg@ti.com \
    --to=dannenberg@ti.com \
    --cc=u-boot@lists.denx.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