Commit 0068c92a authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Steven Rostedt (VMware)

init/main.c: Alloc initcall_command_line in do_initcall() and free it

Since initcall_command_line is used as a temporary buffer,
it could be freed after usage. Allocate it in do_initcall()
and free it after used.

Link: http://lkml.kernel.org/r/157867227145.17873.17513760552008505454.stgit@devnote2Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent c1a3c360
...@@ -137,8 +137,6 @@ char __initdata boot_command_line[COMMAND_LINE_SIZE]; ...@@ -137,8 +137,6 @@ char __initdata boot_command_line[COMMAND_LINE_SIZE];
char *saved_command_line; char *saved_command_line;
/* Command line for parameter parsing */ /* Command line for parameter parsing */
static char *static_command_line; static char *static_command_line;
/* Command line for per-initcall parameter parsing */
static char *initcall_command_line;
static char *execute_command; static char *execute_command;
static char *ramdisk_execute_command; static char *ramdisk_execute_command;
...@@ -433,10 +431,6 @@ static void __init setup_command_line(char *command_line) ...@@ -433,10 +431,6 @@ static void __init setup_command_line(char *command_line)
if (!saved_command_line) if (!saved_command_line)
panic("%s: Failed to allocate %zu bytes\n", __func__, len); panic("%s: Failed to allocate %zu bytes\n", __func__, len);
initcall_command_line = memblock_alloc(len, SMP_CACHE_BYTES);
if (!initcall_command_line)
panic("%s: Failed to allocate %zu bytes\n", __func__, len);
static_command_line = memblock_alloc(len, SMP_CACHE_BYTES); static_command_line = memblock_alloc(len, SMP_CACHE_BYTES);
if (!static_command_line) if (!static_command_line)
panic("%s: Failed to allocate %zu bytes\n", __func__, len); panic("%s: Failed to allocate %zu bytes\n", __func__, len);
...@@ -1044,13 +1038,12 @@ static const char *initcall_level_names[] __initdata = { ...@@ -1044,13 +1038,12 @@ static const char *initcall_level_names[] __initdata = {
"late", "late",
}; };
static void __init do_initcall_level(int level) static void __init do_initcall_level(int level, char *command_line)
{ {
initcall_entry_t *fn; initcall_entry_t *fn;
strcpy(initcall_command_line, saved_command_line);
parse_args(initcall_level_names[level], parse_args(initcall_level_names[level],
initcall_command_line, __start___param, command_line, __start___param,
__stop___param - __start___param, __stop___param - __start___param,
level, level, level, level,
NULL, &repair_env_string); NULL, &repair_env_string);
...@@ -1063,9 +1056,20 @@ static void __init do_initcall_level(int level) ...@@ -1063,9 +1056,20 @@ static void __init do_initcall_level(int level)
static void __init do_initcalls(void) static void __init do_initcalls(void)
{ {
int level; int level;
size_t len = strlen(saved_command_line) + 1;
char *command_line;
command_line = kzalloc(len, GFP_KERNEL);
if (!command_line)
panic("%s: Failed to allocate %zu bytes\n", __func__, len);
for (level = 0; level < ARRAY_SIZE(initcall_levels) - 1; level++) {
/* Parser modifies command_line, restore it each time */
strcpy(command_line, saved_command_line);
do_initcall_level(level, command_line);
}
for (level = 0; level < ARRAY_SIZE(initcall_levels) - 1; level++) kfree(command_line);
do_initcall_level(level);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment