diff mbox series

[v2] boot: image: fixup zstd decompression buffer initialization typo

Message ID 20220316193536.3992652-1-cJ-uboot@zougloub.eu
State Accepted
Commit 408e2d5a224d8c62beae4cb1e7a3804abbbb123f
Delegated to: Tom Rini
Headers show
Series [v2] boot: image: fixup zstd decompression buffer initialization typo | expand

Commit Message

Jérôme Carretero March 16, 2022, 7:35 p.m. UTC
The code was mistakenly initializing the input buffer twice.

Tested to be working on BeagleBone by adjusting CONFIG_SYS_BOOTM_LEN to
64MiB (probably works with less) and preparing uImage with:

 cat arch/arm/boot/Image \
  | zstd --ultra -22 --zstd=windowLog=22 \
  > linux.bin.zst

 mkimage -A arm -T kernel uImage -C zstd -d linux.bin.zst \
  -a 0x80008000 -e 0x80008000

Without the windowLog restriction, bootm fails with a zstd decompression
error 7 (window too large), which I haven't troubleshooted.

There should be a bit more documentation on the feature...

Reviewed-by: Simon Glass <sjg@chromium.org>
Fixes: 458b30af66c image: Update image_decomp() to avoid ifdefs
---
 boot/image.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tom Rini March 28, 2022, 2:16 p.m. UTC | #1
On Wed, Mar 16, 2022 at 03:35:36PM -0400, Jérôme Carretero wrote:

> The code was mistakenly initializing the input buffer twice.
> 
> Tested to be working on BeagleBone by adjusting CONFIG_SYS_BOOTM_LEN to
> 64MiB (probably works with less) and preparing uImage with:
> 
>  cat arch/arm/boot/Image \
>   | zstd --ultra -22 --zstd=windowLog=22 \
>   > linux.bin.zst
> 
>  mkimage -A arm -T kernel uImage -C zstd -d linux.bin.zst \
>   -a 0x80008000 -e 0x80008000
> 
> Without the windowLog restriction, bootm fails with a zstd decompression
> error 7 (window too large), which I haven't troubleshooted.
> 
> There should be a bit more documentation on the feature...
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Fixes: 458b30af66c image: Update image_decomp() to avoid ifdefs

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/boot/image.c b/boot/image.c
index 07fa2d3160..121df0c838 100644
--- a/boot/image.c
+++ b/boot/image.c
@@ -500,7 +500,7 @@  int image_decomp(int comp, ulong load, ulong image_start, int type,
 			struct abuf in, out;
 
 			abuf_init_set(&in, image_buf, image_len);
-			abuf_init_set(&in, load_buf, unc_len);
+			abuf_init_set(&out, load_buf, unc_len);
 			ret = zstd_decompress(&in, &out);
 			if (ret >= 0) {
 				image_len = ret;