bootm: improve error message when gzip decompression buffer is too small
authorAristo Chen <jj251510319013@gmail.com>
Wed, 30 Apr 2025 02:23:25 +0000 (10:23 +0800)
committerTom Rini <trini@konsulko.com>
Mon, 5 May 2025 20:16:57 +0000 (14:16 -0600)
commitf717d798becf2dffd5816484962c350808e98a18
tree0f12139562f07d875e0e78f23015dcb696543629
parent03f5101ff50d1b449c65a4483c725b4ae0446c62
bootm: improve error message when gzip decompression buffer is too small

Currently, when decompressing a gzip-compressed image during bootm, a
generic error such as "inflate() returned -5" is shown when the buffer is
too small. However, it is not immediately clear that this is caused by
CONFIG_SYS_BOOTM_LEN being too small.

This patch improves error handling by:
- Detecting Z_BUF_ERROR (-5) returned from the inflate() call
- Suggesting the user to increase CONFIG_SYS_BOOTM_LEN when applicable
- Preserving the original return code from zunzip() instead of overwriting
  it with -1

By providing clearer hints when decompression fails due to insufficient
buffer size, this change helps users diagnose and fix boot failures more
easily.

Signed-off-by: Aristo Chen <aristo.chen@canonical.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
boot/bootm.c
lib/gunzip.c