Commit 95f6d0ff authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] ppc64: fix cmd_line bugs

From: Anton Blanchard <anton@samba.org>

There were a number of bugs in our cmd_line handling:

- We were looking at cmd_line after it had been tokenised. Use saved_command
  line instead
- Use strlcpy instead of memcpy/explicit NULL set.
- Remove magic numbers in iseries cmd_line parsing
parent f3f62256
...@@ -129,7 +129,6 @@ void __init chrp_request_regions(void) ...@@ -129,7 +129,6 @@ void __init chrp_request_regions(void)
void __init void __init
chrp_setup_arch(void) chrp_setup_arch(void)
{ {
extern char cmd_line[];
struct device_node *root; struct device_node *root;
unsigned int *opprop; unsigned int *opprop;
......
...@@ -247,10 +247,8 @@ void eeh_init(void) ...@@ -247,10 +247,8 @@ void eeh_init(void)
{ {
struct device_node *phb; struct device_node *phb;
struct eeh_early_enable_info info; struct eeh_early_enable_info info;
char *eeh_force_off = strstr(saved_command_line, "eeh-force-off");
extern char cmd_line[]; /* Very early cmd line parse. Cheap, but works. */ char *eeh_force_on = strstr(saved_command_line, "eeh-force-on");
char *eeh_force_off = strstr(cmd_line, "eeh-force-off");
char *eeh_force_on = strstr(cmd_line, "eeh-force-on");
ibm_set_eeh_option = rtas_token("ibm,set-eeh-option"); ibm_set_eeh_option = rtas_token("ibm,set-eeh-option");
ibm_set_slot_reset = rtas_token("ibm,set-slot-reset"); ibm_set_slot_reset = rtas_token("ibm,set-slot-reset");
......
...@@ -2177,4 +2177,4 @@ stab_array: ...@@ -2177,4 +2177,4 @@ stab_array:
*/ */
.globl cmd_line .globl cmd_line
cmd_line: cmd_line:
.space 512 .space 512 /* COMMAND_LINE_SIZE */
...@@ -73,7 +73,6 @@ ...@@ -73,7 +73,6 @@
#include "pmac.h" #include "pmac.h"
extern char saved_command_line[];
static int current_root_goodness = -1; static int current_root_goodness = -1;
#define DEFAULT_ROOT_DEVICE Root_SDA1 /* sda1 - slightly silly choice */ #define DEFAULT_ROOT_DEVICE Root_SDA1 /* sda1 - slightly silly choice */
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include <asm/ppcdebug.h> #include <asm/ppcdebug.h>
#include <asm/btext.h> #include <asm/btext.h>
#include <asm/sections.h> #include <asm/sections.h>
#include <asm/machdep.h>
#include "open_pic.h" #include "open_pic.h"
#ifdef CONFIG_LOGO_LINUX_CLUT224 #ifdef CONFIG_LOGO_LINUX_CLUT224
...@@ -185,7 +186,6 @@ extern void enter_prom(void *dummy,...); ...@@ -185,7 +186,6 @@ extern void enter_prom(void *dummy,...);
extern void copy_and_flush(unsigned long dest, unsigned long src, extern void copy_and_flush(unsigned long dest, unsigned long src,
unsigned long size, unsigned long offset); unsigned long size, unsigned long offset);
extern char cmd_line[512]; /* XXX */
unsigned long dev_tree_size; unsigned long dev_tree_size;
unsigned long _get_PIR(void); unsigned long _get_PIR(void);
...@@ -1512,10 +1512,8 @@ prom_init(unsigned long r3, unsigned long r4, unsigned long pp, ...@@ -1512,10 +1512,8 @@ prom_init(unsigned long r3, unsigned long r4, unsigned long pp,
call_prom(RELOC("getprop"), 4, 1, _prom->chosen, call_prom(RELOC("getprop"), 4, 1, _prom->chosen,
RELOC("bootargs"), p, sizeof(cmd_line)); RELOC("bootargs"), p, sizeof(cmd_line));
if (p != NULL && p[0] != 0) if (p != NULL && p[0] != 0)
strncpy(RELOC(cmd_line), p, sizeof(cmd_line)); strlcpy(RELOC(cmd_line), p, sizeof(cmd_line));
} }
RELOC(cmd_line[sizeof(cmd_line) - 1]) = 0;
mem = prom_initialize_lmb(mem); mem = prom_initialize_lmb(mem);
......
...@@ -477,7 +477,7 @@ static int __init set_preferred_console(void) ...@@ -477,7 +477,7 @@ static int __init set_preferred_console(void)
char *name; char *name;
/* The user has requested a console so this is already set up. */ /* The user has requested a console so this is already set up. */
if (strstr(cmd_line, "console=")) if (strstr(saved_command_line, "console="))
return -EBUSY; return -EBUSY;
prom_stdout = find_path_device(of_stdout_device); prom_stdout = find_path_device(of_stdout_device);
......
...@@ -111,6 +111,7 @@ struct machdep_calls { ...@@ -111,6 +111,7 @@ struct machdep_calls {
extern struct machdep_calls ppc_md; extern struct machdep_calls ppc_md;
#define COMMAND_LINE_SIZE 512 #define COMMAND_LINE_SIZE 512
extern char cmd_line[COMMAND_LINE_SIZE]; extern char cmd_line[COMMAND_LINE_SIZE];
extern char saved_command_line[COMMAND_LINE_SIZE];
/* Functions to produce codes on the leds. /* Functions to produce codes on the leds.
* The SRC code should be unique for the message category and should * The SRC code should be unique for the message category and should
......
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