From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master] efi: payload: image: fix commandline-less boot
Date: Mon, 10 Oct 2022 08:05:10 +0200 [thread overview]
Message-ID: <20221010060510.2082414-1-a.fatoum@pengutronix.de> (raw)
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
next reply other threads:[~2022-10-10 6:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-10 6:05 Ahmad Fatoum [this message]
2022-10-10 7:09 ` Sascha Hauer
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=20221010060510.2082414-1-a.fatoum@pengutronix.de \
--to=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