[PATCH 2/4] cmd: mvebu/bubt: Correctly propagate failure during tftp transport

Stefan Roese sr at denx.de
Thu Jul 28 08:37:28 CEST 2022


On 26.07.22 16:11, Pali Rohár wrote:
> 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 at 30000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
>    ethernet at 30000: No link.
>    Error: Failed to read file flash-image.bin from tftp
> 
> Signed-off-by: Pali Rohár <pali at kernel.org>

Reviewed-by: Stefan Roese <sr at denx.de>

Thanks,
Stefan

> ---
>   cmd/mvebu/bubt.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c
> index a05e22a5479c..2924b1539f32 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)

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de


More information about the U-Boot mailing list