mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
safe filedescriptors
git-svn-id: svn://coreboot.org/openbios/openbios-devel@44 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
@@ -139,5 +139,6 @@ int aout_load(struct sys_info *info, const char *filename, const char *cmdline)
|
||||
retval = 0;
|
||||
|
||||
out:
|
||||
file_close();
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -127,6 +127,7 @@ static unsigned long process_image_notes(Elf_phdr *phdr, int phnum,
|
||||
}
|
||||
}
|
||||
out:
|
||||
file_close();
|
||||
if (buf)
|
||||
free(buf);
|
||||
return retval;
|
||||
@@ -402,6 +403,7 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline)
|
||||
retval = 0;
|
||||
|
||||
out:
|
||||
file_close();
|
||||
if (phdr)
|
||||
free(phdr);
|
||||
if (boot_notes)
|
||||
|
||||
@@ -589,8 +589,10 @@ int linux_load(struct sys_info *info, const char *file, const char *cmdline)
|
||||
return -1;
|
||||
|
||||
kern_addr = load_linux_header(&hdr);
|
||||
if (kern_addr == 0)
|
||||
if (kern_addr == 0) {
|
||||
file_close();
|
||||
return LOADER_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
params = phys_to_virt(LINUX_PARAM_LOC);
|
||||
init_linux_params(params, &hdr);
|
||||
|
||||
@@ -13,6 +13,15 @@ int file_open(const char *filename)
|
||||
return load_fd>-1;
|
||||
}
|
||||
|
||||
void file_close(void)
|
||||
{
|
||||
if(load_fd==-1)
|
||||
return;
|
||||
|
||||
close_io(load_fd);
|
||||
load_fd=-1;
|
||||
}
|
||||
|
||||
int lfile_read(void *buf, unsigned long len)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
Reference in New Issue
Block a user