[PATCH master] efi: payload: image: fix commandline-less boot

Sascha Hauer sha at pengutronix.de
Mon Oct 10 00:09:14 PDT 2022


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 at 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 |



More information about the barebox mailing list