Module Name:    src
Committed By:   mlelstv
Date:           Sat Mar  5 07:33:59 UTC 2016

Modified Files:
        src/sys/arch/evbarm/evbarm: autoconf.c

Log Message:
Don't modify command line buffer but create a copy of the root argument.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/evbarm/evbarm/autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/evbarm/autoconf.c
diff -u src/sys/arch/evbarm/evbarm/autoconf.c:1.18 src/sys/arch/evbarm/evbarm/autoconf.c:1.19
--- src/sys/arch/evbarm/evbarm/autoconf.c:1.18	Sat Nov 22 11:10:22 2014
+++ src/sys/arch/evbarm/evbarm/autoconf.c	Sat Mar  5 07:33:58 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.18 2014/11/22 11:10:22 mlelstv Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.19 2016/03/05 07:33:58 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.18 2014/11/22 11:10:22 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.19 2016/03/05 07:33:58 mlelstv Exp $");
 
 #include "opt_md.h"
 
@@ -41,7 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
 #include <sys/device.h>
 #include <sys/conf.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 
 #include <machine/autoconf.h>
 #include <machine/intr.h>
@@ -95,10 +95,14 @@ get_device(char *name, device_t *dvp, in
 
 /* Set the rootdev variable from the root specifier in the boot args */
 
+static char *bootspec_buf = NULL;
+static size_t bootspec_buflen = 0;
+
 static void
 set_root_device(void)
 {
-	char *ptr, *end;
+	char *ptr, *end, *buf;
+	size_t len;
 
 	if (boot_args == NULL)
 		return;
@@ -112,12 +116,26 @@ set_root_device(void)
 	/* NUL-terminate string, get_bootconf_option doesn't */
 	for (end=ptr; *end != '\0'; ++end) {
 		if (*end == ' ' || *end == '\t') {
-			*end = '\0';
 			break;
 		}
 	}
 
-	bootspec = ptr;
+	if (end == ptr)
+		return;
+
+	len = end - ptr;
+
+	buf = kmem_alloc(len + 1, KM_SLEEP);
+	memcpy(buf, ptr, len);
+	buf[len] = '\0';
+
+	if (bootspec_buf != NULL)
+		kmem_free(bootspec_buf, bootspec_buflen + 1);
+
+	bootspec_buf = buf;
+	bootspec_buflen = len;
+
+	bootspec = bootspec_buf;
 }
 #endif
 

Reply via email to