Skip to content

Commit 477d084

Browse files
mhiramatrostedt
authored andcommitted
bootconfig: Fix to find the initargs correctly
Since the parse_args() stops parsing at '--', bootconfig_params() will never get the '--' as param and initargs_found never be true. In the result, if we pass some init arguments via the bootconfig, those are always appended to the kernel command line with '--' even if the kernel command line already has '--'. To fix this correctly, check the return value of parse_args() and set initargs_found true if the return value is not an error but a valid address. Link: https://lkml.kernel.org/r/159650953285.270383.14822353843556363851.stgit@devnote2 Fixes: f61872b ("bootconfig: Use parse_args() to find bootconfig and '--'") Cc: [email protected] Reported-by: Arvind Sankar <[email protected]> Suggested-by: Arvind Sankar <[email protected]> Signed-off-by: Masami Hiramatsu <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent c58b46c commit 477d084

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

init/main.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,6 @@ static int __init bootconfig_params(char *param, char *val,
387387
{
388388
if (strcmp(param, "bootconfig") == 0) {
389389
bootconfig_found = true;
390-
} else if (strcmp(param, "--") == 0) {
391-
initargs_found = true;
392390
}
393391
return 0;
394392
}
@@ -399,19 +397,23 @@ static void __init setup_boot_config(const char *cmdline)
399397
const char *msg;
400398
int pos;
401399
u32 size, csum;
402-
char *data, *copy;
400+
char *data, *copy, *err;
403401
int ret;
404402

405403
/* Cut out the bootconfig data even if we have no bootconfig option */
406404
data = get_boot_config_from_initrd(&size, &csum);
407405

408406
strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE);
409-
parse_args("bootconfig", tmp_cmdline, NULL, 0, 0, 0, NULL,
410-
bootconfig_params);
407+
err = parse_args("bootconfig", tmp_cmdline, NULL, 0, 0, 0, NULL,
408+
bootconfig_params);
411409

412-
if (!bootconfig_found)
410+
if (IS_ERR(err) || !bootconfig_found)
413411
return;
414412

413+
/* parse_args() stops at '--' and returns an address */
414+
if (err)
415+
initargs_found = true;
416+
415417
if (!data) {
416418
pr_err("'bootconfig' found on command line, but no bootconfig found\n");
417419
return;

0 commit comments

Comments
 (0)