mm: Catch allocation failure
authorBarret Rhoden <brho@cs.berkeley.edu>
Thu, 29 Mar 2018 18:54:53 +0000 (14:54 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 30 Apr 2018 18:36:28 +0000 (14:36 -0400)
Given all this code is hokey, at least we'll panic instead of crashing.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/src/mm.c

index 3fa0772..1cc8783 100644 (file)
@@ -311,6 +311,7 @@ static struct vm_region *split_vmr(struct vm_region *old_vmr, uintptr_t va)
        if ((old_vmr->vm_base >= va) || (old_vmr->vm_end <= va))
                return 0;
        new_vmr = kmem_cache_alloc(vmr_kcache, 0);
+       assert(new_vmr);
        TAILQ_INSERT_AFTER(&old_vmr->vm_proc->vm_regions, old_vmr, new_vmr,
                           vm_link);
        new_vmr->vm_proc = old_vmr->vm_proc;