summaryrefslogtreecommitdiffstats
path: root/common/efi
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-10-10 08:05:10 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-10-10 08:16:51 +0200
commit2ddaeb424c69baddb8dc0c5d3374c31a3b54e3fb (patch)
tree3d5fb2f96f3fa7ad6db4087450c317f1a7c9d4bc /common/efi
parentb20d4dbbda81b8613efdb21f4d3f8a21c50b1b96 (diff)
downloadbarebox-2ddaeb424c69baddb8dc0c5d3374c31a3b54e3fb.tar.gz
barebox-2ddaeb424c69baddb8dc0c5d3374c31a3b54e3fb.tar.xz
efi: payload: image: fix commandline-less boot
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> Link: https://lore.barebox.org/20221010060510.2082414-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/efi')
-rw-r--r--common/efi/payload/image.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/common/efi/payload/image.c b/common/efi/payload/image.c
index e63da9ddf0..8e39098ae8 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;