svn commit: r235094 - head/sys/boot/uboot/common
Tim Kientzle
kientzle at FreeBSD.org
Sun May 6 16:01:59 UTC 2012
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);
}
More information about the svn-src-head
mailing list