summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-06-29 00:45:25 -0400
committerIan Moffett <ian@osmora.org>2024-06-29 00:45:25 -0400
commit1bcdbcf7b9b38de99c73ca44b6b9ea7785deaac7 (patch)
tree638db3c3fe17e1a286d2ece293dc7ec6c4e0f7f4 /sys
parenta63efc16e5e25919881c18cbce74bfd5a42cbcb8 (diff)
kernel: elf: Cleanup error handling
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/exec_elf64.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/sys/kern/exec_elf64.c b/sys/kern/exec_elf64.c
index 4f441b2..8e15839 100644
--- a/sys/kern/exec_elf64.c
+++ b/sys/kern/exec_elf64.c
@@ -176,14 +176,14 @@ elf64_load(const char *pathname, struct proc *td, struct exec_prog *prog)
struct pcb *pcbp;
struct exec_range loadmap[MAX_PHDRS];
struct auxval *auxvalp;
- int error = 0;
+ int status = 0;
- if ((error = elf_get_file(pathname, &file)) != 0)
- return error;
+ if ((status = elf_get_file(pathname, &file)) != 0)
+ return status;
hdr = (Elf64_Ehdr *)file.data;
- if ((error = elf64_verify(hdr)) != 0)
- return error;
+ if ((status = elf64_verify(hdr)) != 0)
+ goto done;
pcbp = &td->pcb;
@@ -204,14 +204,14 @@ elf64_load(const char *pathname, struct proc *td, struct exec_prog *prog)
/* Try to allocate page frames */
physmem = vm_alloc_frame(page_count);
if (physmem == 0) {
- error = -ENOMEM;
+ status = -ENOMEM;
break;
}
- error = vm_map(pcbp->addrsp, phdr->p_vaddr, physmem,
+ status = vm_map(pcbp->addrsp, phdr->p_vaddr, physmem,
prot, map_len);
- if (error != 0) {
+ if (status != 0) {
break;
}
@@ -230,12 +230,12 @@ elf64_load(const char *pathname, struct proc *td, struct exec_prog *prog)
auxvalp->at_phnum = hdr->e_phnum;
/* Did program header loading fail? */
- if (error != 0) {
+ if (status != 0) {
elf_unload(td, prog);
- dynfree(file.data);
- return error;
+ goto done;
}
+done:
dynfree(file.data);
- return 0;
+ return status;
}