diff options
author | Pali Rohár <pali@kernel.org> | 2022-07-26 16:11:57 +0200 |
---|---|---|
committer | Stefan Roese <sr@denx.de> | 2022-07-29 10:02:43 +0200 |
commit | 4b9521f2421cef5d93682879e86933d25f8ac294 (patch) | |
tree | bcc2a752e3f7a4b6620eb2d0dcd2ba401c39ea1a /cmd/mvebu | |
parent | 5d2f7d306cecaf454569fd787855ba1106499400 (diff) |
cmd: mvebu/bubt: Correctly propagate failure during tftp transport
net_loop() returns signed int type and negative value represents error.
tftp_read_file() returns unsigned size_t type and zero value represents
error. Casting signed negative value to unsigned size_t type cause losing
information about error and bubt thinks that no error happened, and
continue erasing SPI-NOR which cause malfunction device.
Fix this issue by correctly propagating failure during tftp transport.
With this change when there is no eth link, bubt does not erase SPI-NOR
anymore.
=> bubt
Burning U-Boot image "flash-image.bin" from "tftp" to "spi"
ethernet@30000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
ethernet@30000: No link.
Error: Failed to read file flash-image.bin from tftp
Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'cmd/mvebu')
-rw-r--r-- | cmd/mvebu/bubt.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c index a05e22a547..2924b1539f 100644 --- a/cmd/mvebu/bubt.c +++ b/cmd/mvebu/bubt.c @@ -455,11 +455,14 @@ static int is_usb_active(void) #ifdef CONFIG_CMD_NET static size_t tftp_read_file(const char *file_name) { + int ret; + /* * update global variable image_load_addr before tftp file from network */ image_load_addr = get_load_addr(); - return net_loop(TFTPGET); + ret = net_loop(TFTPGET); + return ret > 0 ? ret : 0; } static int is_tftp_active(void) |