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.
This commit is contained in:
Tim Kientzle 2012-05-06 16:01:58 +00:00
parent 8c501e516b
commit 5bf877dace
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=235094
2 changed files with 18 additions and 4 deletions

View file

@ -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 */

View file

@ -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);
}