Fix pop_fstr_copy memory leaks

- console one prevented Debian 3.1r1 from installing in console=prom mode
- fixing this also needed the real malloc/free



git-svn-id: svn://coreboot.org/openbios/openbios-devel@155 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Blue Swirl
2007-06-27 20:16:01 +00:00
parent 8980119c27
commit e3db406e09
5 changed files with 21 additions and 9 deletions

View File

@@ -45,18 +45,18 @@ void boot(void)
} else { } else {
switch (boot_device) { switch (boot_device) {
case 'a': case 'a':
path = "/obio/SUNW,fdtwo"; path = strdup("/obio/SUNW,fdtwo");
oldpath = "fd()"; oldpath = "fd()";
unit = 0; unit = 0;
break; break;
case 'c': case 'c':
path = "disk"; path = strdup("disk");
oldpath = "sd(0,0,0):d"; oldpath = "sd(0,0,0):d";
unit = 0; unit = 0;
break; break;
default: default:
case 'd': case 'd':
path = "cdrom"; path = strdup("cdrom");
// FIXME: hardcoding this looks almost definitely wrong. // FIXME: hardcoding this looks almost definitely wrong.
// With sd(0,2,0):b we get to see the solaris kernel though // With sd(0,2,0):b we get to see the solaris kernel though
//oldpath = "sd(0,2,0):d"; //oldpath = "sd(0,2,0):d";
@@ -64,7 +64,7 @@ void boot(void)
unit = 2; unit = 2;
break; break;
case 'n': case 'n':
path = "net"; path = strdup("net");
oldpath = "le()"; oldpath = "le()";
unit = 0; unit = 0;
break; break;

View File

@@ -279,8 +279,14 @@ ob_sd_open(__attribute__((unused))sd_private_t **sd)
*sd = &global_esp->sd[id]; *sd = &global_esp->sd[id];
#ifdef CONFIG_DEBUG_ESP #ifdef CONFIG_DEBUG_ESP
fword("my-args"); {
DPRINTF("opening drive %d args %s\n", id, pop_fstr_copy()); char *args;
fword("my-args");
args = pop_fstr_copy();
DPRINTF("opening drive %d args %s\n", id, args);
free(args);
}
#endif #endif
selfword("open-deblocker"); selfword("open-deblocker");

View File

@@ -223,10 +223,13 @@ zs_open(unsigned long *address)
*address = *prop; *address = *prop;
fword("my-args"); fword("my-args");
args = pop_fstr_copy(); args = pop_fstr_copy();
if (args && args[0] == 'a') if (args) {
*address += 4; if (args[0] == 'a')
*address += 4;
//printk("zs_open: address %lx, args %s\n", *address, args);
free(args);
}
//printk("zs_open: address %lx, args %s\n", *address, args);
RET ( -1 ); RET ( -1 );
} }

View File

@@ -253,6 +253,8 @@ pop_fstr_copy( void )
if( !len ) if( !len )
return NULL; return NULL;
str = malloc( len + 1 ); str = malloc( len + 1 );
if( !str )
return NULL;
memcpy( str, p, len ); memcpy( str, p, len );
str[len] = 0; str[len] = 0;
return str; return str;

View File

@@ -253,6 +253,7 @@ video_write(void)
addr = pop_fstr_copy(); addr = pop_fstr_copy();
console_draw_str(addr); console_draw_str(addr);
free(addr);
PUSH(len); PUSH(len);
} }