]> git.hungrycats.org Git - linux/commitdiff
[PATCH] ppc64: fix cmd_line bugs
authorAndrew Morton <akpm@osdl.org>
Mon, 23 Feb 2004 12:50:28 +0000 (04:50 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 23 Feb 2004 12:50:28 +0000 (04:50 -0800)
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

arch/ppc64/kernel/chrp_setup.c
arch/ppc64/kernel/eeh.c
arch/ppc64/kernel/head.S
arch/ppc64/kernel/pmac_setup.c
arch/ppc64/kernel/prom.c
arch/ppc64/kernel/setup.c
include/asm-ppc64/machdep.h

index b112cd9b2ec713f7939707f5fa3582dd57ea81e8..bb0083d1c756695c471537db6ccae1be8d73ccf6 100644 (file)
@@ -129,7 +129,6 @@ void __init chrp_request_regions(void)
 void __init
 chrp_setup_arch(void)
 {
-       extern char cmd_line[];
        struct device_node *root;
        unsigned int *opprop;
        
index c338f57a206d7639166707d8d1b8403ed173c735..c67294aff69e5eb62440838fc78d3087bf31424f 100644 (file)
@@ -247,10 +247,8 @@ void eeh_init(void)
 {
        struct device_node *phb;
        struct eeh_early_enable_info info;
-
-       extern char cmd_line[]; /* Very early cmd line parse.  Cheap, but works. */
-       char *eeh_force_off = strstr(cmd_line, "eeh-force-off");
-       char *eeh_force_on = strstr(cmd_line, "eeh-force-on");
+       char *eeh_force_off = strstr(saved_command_line, "eeh-force-off");
+       char *eeh_force_on = strstr(saved_command_line, "eeh-force-on");
 
        ibm_set_eeh_option = rtas_token("ibm,set-eeh-option");
        ibm_set_slot_reset = rtas_token("ibm,set-slot-reset");
index e4d46294d2671017666823e8a0910a9023080a17..f1600468546a06ada508330900ed3009b754b9eb 100644 (file)
@@ -2177,4 +2177,4 @@ stab_array:
  */
        .globl  cmd_line
 cmd_line:
-       .space  512
+       .space  512     /* COMMAND_LINE_SIZE */
index 4c33810dc82cb3650471a87c7e6c6fd85a2e7eb6..cffbf60c291dd5cdf111b63260aee72608ff5cb1 100644 (file)
@@ -73,7 +73,6 @@
 
 #include "pmac.h"
 
-extern char saved_command_line[];
 static int current_root_goodness = -1;
 #define DEFAULT_ROOT_DEVICE Root_SDA1  /* sda1 - slightly silly choice */
 
index 5a6182b940d444386789a91fecee03c501d69585..a0e13ed6abde0fb5c3f4f974b4460ed2a1ad13e0 100644 (file)
@@ -52,6 +52,7 @@
 #include <asm/ppcdebug.h>
 #include <asm/btext.h>
 #include <asm/sections.h>
+#include <asm/machdep.h>
 #include "open_pic.h"
 
 #ifdef CONFIG_LOGO_LINUX_CLUT224
@@ -185,7 +186,6 @@ extern void enter_prom(void *dummy,...);
 extern void copy_and_flush(unsigned long dest, unsigned long src,
                           unsigned long size, unsigned long offset);
 
-extern char cmd_line[512];     /* XXX */
 unsigned long dev_tree_size;
 unsigned long _get_PIR(void);
 
@@ -1512,10 +1512,8 @@ prom_init(unsigned long r3, unsigned long r4, unsigned long pp,
                call_prom(RELOC("getprop"), 4, 1, _prom->chosen, 
                          RELOC("bootargs"), p, sizeof(cmd_line));
                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);
 
index cf165ca5353d8b1f4185f9d421de4ba0b5f9329f..232d667abcc3fa07ead7a7648f3888bb24f906ce 100644 (file)
@@ -477,7 +477,7 @@ static int __init set_preferred_console(void)
        char *name;
 
        /* 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;
 
        prom_stdout = find_path_device(of_stdout_device);
index 0b1970bcf151c4e2fd589dbae3c4f7915f448797..d5cf6dc3dcf4a5b8d363fd3c019a6e7c8c063591 100644 (file)
@@ -111,6 +111,7 @@ struct machdep_calls {
 extern struct machdep_calls ppc_md;
 #define COMMAND_LINE_SIZE 512
 extern char cmd_line[COMMAND_LINE_SIZE];
+extern char saved_command_line[COMMAND_LINE_SIZE];
 
 /* Functions to produce codes on the leds.
  * The SRC code should be unique for the message category and should