]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
image: Set load_end on partial loads
authorMattijs Korpershoek <mkorpershoek@baylibre.com>
Thu, 23 May 2024 09:27:09 +0000 (11:27 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 7 Jun 2024 22:20:28 +0000 (16:20 -0600)
When decompressing, it's possible that the algorithm only performs
a partial decompression.
This usually happens when CONFIG_SYS_BOOTM_LEN is too small for
the uncompressed image.

When that happens, image_decomp() returns an error and *load_end == load.
The error is then handled by handle_decomp_error().

handle_decomp_error() expects the number of uncompressed bytes in
uncomp_size but receives *load_end - load == load - load == 0.

Because of this, handle_decomp_error does not report the expected
"Image too large: increase CONFIG_SYS_BOOTM_LEN" error message.

Modify the image_decomp() logic to always report the decompressed size,
even when a partial decompression happened.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
boot/image.c

index bacf5146e13bbe48801e25f6c6f6485327cc7de0..fc774d605d17db8197a7c534ce56f0bc07c01d7b 100644 (file)
@@ -528,10 +528,10 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
                printf("Unimplemented compression type %d\n", comp);
                return ret;
        }
-       if (ret)
-               return ret;
 
        *load_end = load + image_len;
+       if (ret)
+               return ret;
 
        return 0;
 }