Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 May 2012 16:01:59 +0000 (UTC)
From:      Tim Kientzle <kientzle@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r235094 - head/sys/boot/uboot/common
Message-ID:  <201205061601.q46G1xSr021254@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kientzle
Date: Sun May  6 16:01:58 2012
New Revision: 235094
URL: http://svn.freebsd.org/changeset/base/235094

Log:
  Don't call strcmp with a NULL pointer.
  
  In particular, on the AM335x, which comes up with no memory
  mapped to low addresses, dereferencing the NULL causes a crash.

Modified:
  head/sys/boot/uboot/common/main.c
  head/sys/boot/uboot/common/metadata.c

Modified: head/sys/boot/uboot/common/main.c
==============================================================================
--- head/sys/boot/uboot/common/main.c	Sun May  6 15:56:07 2012	(r235093)
+++ head/sys/boot/uboot/common/main.c	Sun May  6 16:01:58 2012	(r235094)
@@ -116,6 +116,16 @@ meminfo(void)
 	}
 }
 
+static uint64_t
+uboot_loadaddr(u_int type, void *data, uint64_t addr)
+{
+	printf("uboot_loadaddr: type=%d data=0x%x addr=0x%x\n",
+	    type, data, addr);
+	if (type == 1)
+		return 0x40000000;
+	return (addr);
+}
+
 int
 main(void)
 {
@@ -211,6 +221,7 @@ main(void)
 	archsw.arch_copyout = uboot_copyout;
 	archsw.arch_readin = uboot_readin;
 	archsw.arch_autoload = uboot_autoload;
+	archsw.arch_loadaddr = uboot_loadaddr;
 
 	interact();				/* doesn't return */
 

Modified: head/sys/boot/uboot/common/metadata.c
==============================================================================
--- head/sys/boot/uboot/common/metadata.c	Sun May  6 15:56:07 2012	(r235093)
+++ head/sys/boot/uboot/common/metadata.c	Sun May  6 16:01:58 2012	(r235094)
@@ -72,6 +72,7 @@ static int
 md_getboothowto(char *kargs)
 {
 	char	*cp;
+	char	*p;
 	int	howto;
 	int	active;
 	int	i;
@@ -132,10 +133,12 @@ md_getboothowto(char *kargs)
 		if (getenv(howto_names[i].ev) != NULL)
 			howto |= howto_names[i].mask;
 	}
-	if (!strcmp(getenv("console"), "comconsole"))
-		howto |= RB_SERIAL;
-	if (!strcmp(getenv("console"), "nullconsole"))
-		howto |= RB_MUTE;
+	if ((p = getenv("console"))) {
+		if (!strcmp(p, "comconsole"))
+			howto |= RB_SERIAL;
+		if (!strcmp(p, "nullconsole"))
+			howto |= RB_MUTE;
+	}
 
 	return(howto);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201205061601.q46G1xSr021254>