summaryrefslogtreecommitdiff
path: root/kern
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2016-10-21 17:23:06 +0200
committerJustus Winter <justus@gnupg.org>2016-10-21 17:59:18 +0200
commit260d0254d3dd8b2cb0b062a255f1c4201566b5a8 (patch)
tree7f3938e2d64be26e9b86badc08571d7ea2b826bd /kern
parent834a883acdbdfa3fc93a9b635d20f4d636a1be41 (diff)
Gracefully handle pmap allocation failures.
* kern/task.c (task_create): Gracefully handle pmap allocation failures. * vm/vm_map.c (vm_map_fork): Likewise.
Diffstat (limited to 'kern')
-rw-r--r--kern/task.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/kern/task.c b/kern/task.c
index 7dff1249..1874af69 100644
--- a/kern/task.c
+++ b/kern/task.c
@@ -100,13 +100,24 @@ kern_return_t task_create(
new_task->map = kernel_map;
} else if (inherit_memory) {
new_task->map = vm_map_fork(parent_task->map);
- vm_map_set_name(new_task->map, new_task->name);
} else {
- new_task->map = vm_map_create(pmap_create(0),
+ pmap_t new_pmap = pmap_create((vm_size_t) 0);
+ if (new_pmap == PMAP_NULL)
+ new_task->map = VM_MAP_NULL;
+ else {
+ new_task->map = vm_map_create(new_pmap,
round_page(VM_MIN_ADDRESS),
trunc_page(VM_MAX_ADDRESS));
- vm_map_set_name(new_task->map, new_task->name);
+ if (new_task->map == VM_MAP_NULL)
+ pmap_destroy(new_pmap);
+ }
}
+ if (new_task->map == VM_MAP_NULL) {
+ kmem_cache_free(&task_cache, (vm_address_t) new_task);
+ return KERN_RESOURCE_SHORTAGE;
+ }
+ if (child_task != &kernel_task)
+ vm_map_set_name(new_task->map, new_task->name);
simple_lock_init(&new_task->lock);
queue_init(&new_task->thread_list);