diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2015-11-29 14:29:06 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2015-11-29 14:29:06 +0100 |
commit | 65479ae46bf058a89eb4e21478f8b4b592f335a9 (patch) | |
tree | 03e0f52f63fdafba95a83a31551245a81e49cec1 | |
parent | 9fa2e66de104f5a310d643939c8d3e547b4c29d6 (diff) |
Nicer out of memory condition reporting
* vm/vm_object.c (_vm_object_allocate): Return 0 immediately when
kmem_cache_alloc returned 0.
(vm_object_allocate): Panic when _vm_object_allocate returns 0.
-rw-r--r-- | vm/vm_object.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/vm/vm_object.c b/vm/vm_object.c index 133181f..dd63481 100644 --- a/vm/vm_object.c +++ b/vm/vm_object.c @@ -228,6 +228,8 @@ vm_object_t _vm_object_allocate( vm_object_t object; object = (vm_object_t) kmem_cache_alloc(&vm_object_cache); + if (!object) + return 0; _vm_object_setup(object, size); @@ -241,6 +243,8 @@ vm_object_t vm_object_allocate( ipc_port_t port; object = _vm_object_allocate(size); + if (object == 0) + panic("vm_object_allocate"); port = ipc_port_alloc_kernel(); if (port == IP_NULL) panic("vm_object_allocate"); |