summaryrefslogtreecommitdiff
path: root/usr.sbin/vmd
diff options
context:
space:
mode:
authorMike Larkin <mlarkin@cvs.openbsd.org>2016-01-05 06:54:04 +0000
committerMike Larkin <mlarkin@cvs.openbsd.org>2016-01-05 06:54:04 +0000
commitc799c0e48fc612528a8934887917c585198a859d (patch)
tree020384f535bb8b9b9ca34578a16451f9d649d883 /usr.sbin/vmd
parentd8e399b2a70ec196b3a4d9046fc8e70addfe907e (diff)
Fail fast if elf64_exec fails. No need to populate the bootargs/stack
and gdt pages if we couldn't load the kernel. diff from Michal Mazurek, thanks!
Diffstat (limited to 'usr.sbin/vmd')
-rw-r--r--usr.sbin/vmd/loadfile_elf.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.sbin/vmd/loadfile_elf.c b/usr.sbin/vmd/loadfile_elf.c
index d278bafd713..3c57457de87 100644
--- a/usr.sbin/vmd/loadfile_elf.c
+++ b/usr.sbin/vmd/loadfile_elf.c
@@ -1,5 +1,5 @@
/* $NetBSD: loadfile.c,v 1.10 2000/12/03 02:53:04 tsutsui Exp $ */
-/* $OpenBSD: loadfile_elf.c,v 1.6 2016/01/05 06:51:54 mlarkin Exp $ */
+/* $OpenBSD: loadfile_elf.c,v 1.7 2016/01/05 06:54:03 mlarkin Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -233,6 +233,9 @@ loadelf_main(int fd, int vm_id_in, int mem_sz, struct vcpu_init_state *vis)
r = elf64_exec(fd, &hdr.elf64, marks, LOAD_ALL);
}
+ if (r)
+ return (r);
+
push_bootargs(mem_sz);
push_gdt();
stacksize = push_stack(mem_sz, marks[MARK_END]);
@@ -241,7 +244,7 @@ loadelf_main(int fd, int vm_id_in, int mem_sz, struct vcpu_init_state *vis)
vis->vis_rsp = (uint64_t)(STACK_PAGE + PAGE_SIZE) - stacksize;
vis->vis_gdtr.vsi_base = GDT_PAGE;
- return r;
+ return (0);
}
/*