From: Tom Rini <trini@konsulko.com>
To: 陳偉銘 <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: Tue, 29 Apr 2025 08:15:29 -0600 [thread overview]
Message-ID: <20250429141529.GD1261075@bill-the-cat> (raw)
In-Reply-To: <CAJwFiG++7ikLUQBGiz8QXsY=R4WQkWnsWC_ETan5syk-poTu_w@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2646 bytes --]
On Tue, Apr 29, 2025 at 06:08:50PM +0800, 陳偉銘 wrote:
> Tom Rini <trini@konsulko.com> 於 2025年4月29日 週二 上午1:24寫道:
> >
> > 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");
> >
> Thanks for your suggestion! I am not sure if I get it correctly, do
> you mean that we should remove the original if condition( if
> (uncomp_size >= buf_size) ) that prints the error message?
Ah sorry for being unclear. I just meant we can handle the new print
more directly.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
next prev parent reply other threads:[~2025-04-29 14:15 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
2025-04-29 10:08 ` 陳偉銘
2025-04-29 14:15 ` Tom Rini [this message]
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=20250429141529.GD1261075@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