mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] efi: payload: image: fix commandline-less boot
@ 2022-10-10  6:05 Ahmad Fatoum
  2022-10-10  7:09 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2022-10-10  6:05 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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(-)

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH master] efi: payload: image: fix commandline-less boot
  2022-10-10  6:05 [PATCH master] efi: payload: image: fix commandline-less boot Ahmad Fatoum
@ 2022-10-10  7:09 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2022-10-10  7:09 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

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 |



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-10  7:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-10  6:05 [PATCH master] efi: payload: image: fix commandline-less boot Ahmad Fatoum
2022-10-10  7:09 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox