]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
common: update: Fix TFTP return value handling
authorMarek Vasut <marek.vasut+renesas@mailbox.org>
Mon, 20 Apr 2026 01:23:07 +0000 (03:23 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 24 Apr 2026 17:28:14 +0000 (11:28 -0600)
The net_loop() returns 1 on success, but update_load() returns 0 on
success. Do not assign rv which is the return value of update_load()
to net_loop(), instead assign net_loop() return value to a temporary
variable and then update rv only if the temporary variable is negative.
This way the update_load() now correctly returns 0 on tftp success and
1 only on failure.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
common/update.c

index 0bafffede9e7560c4d94068f787522940794059d..06e53cbd402f141b8e40ae888bbf6440cfcb71a3 100644 (file)
@@ -32,7 +32,7 @@ static uchar *saved_prot_info;
 #endif
 static int update_load(char *filename, ulong msec_max, int cnt_max, ulong addr)
 {
-       int rv;
+       int rv, ret;
        ulong saved_timeout_msecs;
        int saved_timeout_count;
        char *saved_netretry, *saved_bootfile;
@@ -54,9 +54,9 @@ static int update_load(char *filename, ulong msec_max, int cnt_max, ulong addr)
        /* download the update file */
        image_load_addr = addr;
        copy_filename(net_boot_file_name, filename, sizeof(net_boot_file_name));
-       rv = net_loop(TFTPGET);
+       ret = net_loop(TFTPGET);
 
-       if (rv < 0)
+       if (ret < 0)
                rv = 1;
        else
                flush_cache(addr, net_boot_file_size);