From: Tom Rini <trini@konsulko.com>
To: Aristo Chen <jj251510319013@gmail.com>
Cc: u-boot@lists.denx.de, aristo.chen@canonical.com,
sjg@chromium.org, ilias.apalodimas@linaro.org,
sughosh.ganu@linaro.org, mkorpershoek@kernel.org,
Zone.Niuzh@hotmail.com
Subject: Re: [PATCH] bootm: improve error message when gzip decompression buffer is too small
Date: Mon, 28 Apr 2025 11:24:39 -0600 [thread overview]
Message-ID: <20250428172439.GD5495@bill-the-cat> (raw)
In-Reply-To: <20250428060757.125596-1-aristo.chen@canonical.com>
[-- Attachment #1: Type: text/plain, Size: 1943 bytes --]
On Mon, Apr 28, 2025 at 02:07:57PM +0800, Aristo Chen wrote:
> 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>
I like the concept but:
> @@ -573,12 +574,26 @@ static int handle_decomp_error(int comp_type, size_t uncomp_size,
> size_t buf_size, int ret)
> {
> const char *name = genimg_get_comp_name(comp_type);
> + bool likely_buf_too_small = false;
>
> /* ENOSYS means unimplemented compression type, don't reset. */
> if (ret == -ENOSYS)
> return BOOTM_ERR_UNIMPLEMENTED;
>
> + switch (comp_type) {
> + case IH_COMP_GZIP:
> + if (ret == Z_BUF_ERROR) /* -5 */
> + likely_buf_too_small = true;
> + break;
> + // Add more if necessary
> + default:
> + break;
> + }
> +
> if (uncomp_size >= buf_size)
> + likely_buf_too_small = true;
> +
> + if (likely_buf_too_small)
> printf("Image too large: increase CONFIG_SYS_BOOTM_LEN\n");
> else
> printf("%s: uncompress error %d\n", name, ret);
This is a lot of code, why not just:
if (comp_type == IH_COMP_GZIP && ret == Z_BUF_ERROR)
printf("Image too large: increase CONFIG_SYS_BOOTM_LEN\n");
And we can expand the tests for other algorithms either later or in
follow-up. Thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
next prev parent reply other threads:[~2025-04-28 17:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-28 6:07 [PATCH] bootm: improve error message when gzip decompression buffer is too small Aristo Chen
2025-04-28 17:24 ` Tom Rini [this message]
2025-04-29 10:08 ` 陳偉銘
2025-04-29 14:15 ` Tom Rini
2025-04-29 15:15 ` Aristo Chen
2025-04-29 19:17 ` Tom Rini
2025-04-30 2:23 ` [PATCH v2 1/1] " Aristo Chen
2025-04-30 14:36 ` Tom Rini
2025-04-30 14:56 ` Mattijs Korpershoek
2025-05-05 23:35 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250428172439.GD5495@bill-the-cat \
--to=trini@konsulko.com \
--cc=Zone.Niuzh@hotmail.com \
--cc=aristo.chen@canonical.com \
--cc=ilias.apalodimas@linaro.org \
--cc=jj251510319013@gmail.com \
--cc=mkorpershoek@kernel.org \
--cc=sjg@chromium.org \
--cc=sughosh.ganu@linaro.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox