mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH master] efi: payload: image: fix commandline-less boot
Date: Mon, 10 Oct 2022 09:09:14 +0200	[thread overview]
Message-ID: <20221010070914.GD986@pengutronix.de> (raw)
In-Reply-To: <20221010060510.2082414-1-a.fatoum@pengutronix.de>

On Mon, Oct 10, 2022 at 08:05:10AM +0200, Ahmad Fatoum wrote:
> linux_bootargs_get() may return NULL, in that case we should avoid
> calling strlen on it.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  common/efi/payload/image.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/common/efi/payload/image.c b/common/efi/payload/image.c
> index e63da9ddf06f..8e39098ae81b 100644
> --- a/common/efi/payload/image.c
> +++ b/common/efi/payload/image.c
> @@ -133,9 +133,11 @@ static int efi_execute_image(const char *file)
>  		pr_debug("Linux kernel detected. Adding bootargs.");
>  		options = linux_bootargs_get();
>  		pr_err("add linux options '%s'\n", options);
> -		loaded_image->load_options = xstrdup_char_to_wchar(options);
> -		loaded_image->load_options_size =
> -			(strlen(options) + 1) * sizeof(wchar_t);
> +		if (options) {
> +			loaded_image->load_options = xstrdup_char_to_wchar(options);
> +			loaded_image->load_options_size =
> +				(strlen(options) + 1) * sizeof(wchar_t);
> +		}
>  		shutdown_barebox();
>  	}
>  
> @@ -227,8 +229,10 @@ static int do_bootm_efi(struct image_data *data)
>  	}
>  
>  	options = linux_bootargs_get();
> -	boot_header->cmd_line_ptr = (uint64_t)options;
> -	boot_header->cmdline_size = strlen(options);
> +	if (options) {
> +		boot_header->cmd_line_ptr = (uint64_t)options;
> +		boot_header->cmdline_size = strlen(options);
> +	}
>  
>  	boot_header->code32_start = (uint64_t)loaded_image->image_base +
>  			(image_header->setup_sects+1) * 512;
> -- 
> 2.30.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      reply	other threads:[~2022-10-10  7:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-10  6:05 Ahmad Fatoum
2022-10-10  7:09 ` Sascha Hauer [this message]

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=20221010070914.GD986@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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