summaryrefslogtreecommitdiff
path: root/sys/arch/i386
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2010-11-20 20:21:14 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2010-11-20 20:21:14 +0000
commit38b5bfa422ec365c97db56767a140eb2e1df97e1 (patch)
tree4c11292c1304841dee0d1dcc7d465422d33f7d59 /sys/arch/i386
parent2abd7164dc538564c0660ef190a5ff06940a53a8 (diff)
Check uvm_km_alloc() return values; pmap_fork() will currently panic,
while i386_set_ldt() can fail gracefully. To be improved eventually. From mpech@ sometime ago. ok deraadt@ kettenis@
Diffstat (limited to 'sys/arch/i386')
-rw-r--r--sys/arch/i386/i386/pmap.c6
-rw-r--r--sys/arch/i386/i386/sys_machdep.c6
2 files changed, 10 insertions, 2 deletions
diff --git a/sys/arch/i386/i386/pmap.c b/sys/arch/i386/i386/pmap.c
index 37dc4537f3b..7895ffa2a57 100644
--- a/sys/arch/i386/i386/pmap.c
+++ b/sys/arch/i386/i386/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.148 2010/05/08 16:54:08 oga Exp $ */
+/* $OpenBSD: pmap.c,v 1.149 2010/11/20 20:21:13 miod Exp $ */
/* $NetBSD: pmap.c,v 1.91 2000/06/02 17:46:37 thorpej Exp $ */
/*
@@ -1597,6 +1597,10 @@ pmap_fork(struct pmap *pmap1, struct pmap *pmap2)
len = pmap1->pm_ldt_len * sizeof(union descriptor);
new_ldt = (union descriptor *)uvm_km_alloc(kernel_map, len);
+ if (new_ldt == NULL) {
+ /* XXX needs to be able to fail properly */
+ panic("pmap_fork: out of kva");
+ }
bcopy(pmap1->pm_ldt, new_ldt, len);
pmap2->pm_ldt = new_ldt;
pmap2->pm_ldt_len = pmap1->pm_ldt_len;
diff --git a/sys/arch/i386/i386/sys_machdep.c b/sys/arch/i386/i386/sys_machdep.c
index e365d2e1de7..16a28e3634d 100644
--- a/sys/arch/i386/i386/sys_machdep.c
+++ b/sys/arch/i386/i386/sys_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_machdep.c,v 1.26 2006/09/19 11:06:33 jsg Exp $ */
+/* $OpenBSD: sys_machdep.c,v 1.27 2010/11/20 20:21:13 miod Exp $ */
/* $NetBSD: sys_machdep.c,v 1.28 1996/05/03 19:42:29 christos Exp $ */
/*-
@@ -264,6 +264,10 @@ i386_set_ldt(struct proc *p, void *args, register_t *retval)
simple_unlock(&pmap->pm_lock);
new_ldt = (union descriptor *)uvm_km_alloc(kernel_map,
new_len);
+ if (new_ldt == NULL) {
+ error = ENOMEM;
+ goto out;
+ }
simple_lock(&pmap->pm_lock);
if (pmap->pm_ldt != NULL && ldt_len <= pmap->pm_ldt_len) {