U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mattijs Korpershoek <mkorpershoek@kernel.org>
To: Aristo Chen <jj251510319013@gmail.com>, u-boot@lists.denx.de
Cc: aristo.chen@canonical.com, trini@konsulko.com, sjg@chromium.org,
	ilias.apalodimas@linaro.org, sughosh.ganu@linaro.org,
	mkorpershoek@kernel.org, Zone.Niuzh@hotmail.com
Subject: Re: [PATCH v2 1/1] bootm: improve error message when gzip decompression buffer is too small
Date: Wed, 30 Apr 2025 16:56:25 +0200	[thread overview]
Message-ID: <87r019r946.fsf@kernel.org> (raw)
In-Reply-To: <20250430022325.156922-1-aristo.chen@canonical.com>

Hi Aristo,

Thank you for the patch.

On mer., avril 30, 2025 at 10:23, Aristo Chen <jj251510319013@gmail.com> 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>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>

> ---
>  boot/bootm.c | 4 +++-
>  lib/gunzip.c | 2 +-
>  2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/boot/bootm.c b/boot/bootm.c
> index f5cbb10f0d1..f6aa32746b7 100644
> --- a/boot/bootm.c
> +++ b/boot/bootm.c
> @@ -34,6 +34,7 @@
>  
>  #include <bootm.h>
>  #include <image.h>
> +#include <u-boot/zlib.h>
>  
>  #define MAX_CMDLINE_SIZE	SZ_4K
>  
> @@ -578,7 +579,8 @@ static int handle_decomp_error(int comp_type, size_t uncomp_size,
>  	if (ret == -ENOSYS)
>  		return BOOTM_ERR_UNIMPLEMENTED;
>  
> -	if (uncomp_size >= buf_size)
> +	if ((comp_type == IH_COMP_GZIP && ret == Z_BUF_ERROR) ||
> +	    uncomp_size >= buf_size)
>  		printf("Image too large: increase CONFIG_SYS_BOOTM_LEN\n");
>  	else
>  		printf("%s: uncompress error %d\n", name, ret);
> diff --git a/lib/gunzip.c b/lib/gunzip.c
> index 52007715bda..a05dcde9a75 100644
> --- a/lib/gunzip.c
> +++ b/lib/gunzip.c
> @@ -299,7 +299,7 @@ __rcode int zunzip(void *dst, int dstlen, unsigned char *src,
>  		if (stoponerr == 1 && r != Z_STREAM_END &&
>  		    (s.avail_in == 0 || s.avail_out == 0 || r != Z_BUF_ERROR)) {
>  			printf("Error: inflate() returned %d\n", r);
> -			err = -1;
> +			err = r;
>  			break;
>  		}
>  	} while (r == Z_BUF_ERROR);
> -- 
> 2.34.1

  parent reply	other threads:[~2025-04-30 14:56 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
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 [this message]
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=87r019r946.fsf@kernel.org \
    --to=mkorpershoek@kernel.org \
    --cc=Zone.Niuzh@hotmail.com \
    --cc=aristo.chen@canonical.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jj251510319013@gmail.com \
    --cc=sjg@chromium.org \
    --cc=sughosh.ganu@linaro.org \
    --cc=trini@konsulko.com \
    --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