summaryrefslogtreecommitdiff
path: root/vm
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2015-04-26 15:39:00 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2015-05-20 10:56:15 +0200
commit3c3d3614673c93bf1b1f47d612d8067455d06920 (patch)
tree4632c0c785420609eca295dcb474b08a79042f0a /vm
parent82305c623900ce30a666bd14ae6901a1bf149bb7 (diff)
vm: gracefully handle resource shortage
* vm/vm_object.c (vm_object_copy_call): Gracefully handle resource shortage by doing the allocation earlier and aborting the function if unsuccessful.
Diffstat (limited to 'vm')
-rw-r--r--vm/vm_object.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/vm/vm_object.c b/vm/vm_object.c
index 71c0edb..8c6bbab 100644
--- a/vm/vm_object.c
+++ b/vm/vm_object.c
@@ -1336,16 +1336,6 @@ kern_return_t vm_object_copy_call(
vm_page_t p;
/*
- * Set the backing object for the new
- * temporary object.
- */
-
- assert(src_object->ref_count > 0);
- src_object->ref_count++;
- vm_object_paging_begin(src_object);
- vm_object_unlock(src_object);
-
- /*
* Create a memory object port to be associated
* with this new vm_object.
*
@@ -1358,10 +1348,18 @@ kern_return_t vm_object_copy_call(
*/
new_memory_object = ipc_port_alloc_kernel();
- if (new_memory_object == IP_NULL) {
- panic("vm_object_copy_call: allocate memory object port");
- /* XXX Shouldn't panic here. */
- }
+ if (new_memory_object == IP_NULL)
+ return KERN_RESOURCE_SHORTAGE;
+
+ /*
+ * Set the backing object for the new
+ * temporary object.
+ */
+
+ assert(src_object->ref_count > 0);
+ src_object->ref_count++;
+ vm_object_paging_begin(src_object);
+ vm_object_unlock(src_object);
/* we hold a naked receive right for new_memory_object */
(void) ipc_port_make_send(new_memory_object);