Proactive 0s new vm_region structs
authorBarret Rhoden <brho@cs.berkeley.edu>
Thu, 10 Mar 2011 02:32:22 +0000 (18:32 -0800)
committerKevin Klues <klueska@cs.berkeley.edu>
Thu, 3 Nov 2011 00:36:00 +0000 (17:36 -0700)
This will help catch bugs for now, though if you're using create_vmr(),
be sure to read the comment telling you how to use it!  Caller is
supposed to initialize the extra fields.

kern/src/mm.c

index 9f8e9ef..54d157f 100644 (file)
@@ -55,6 +55,7 @@ struct vm_region *create_vmr(struct proc *p, uintptr_t va, size_t len)
                vmr = kmem_cache_alloc(vmr_kcache, 0);
                if (!vmr)
                        panic("EOM!");
+               memset(vmr, 0, sizeof(struct vm_region));
                vmr->vm_base = va;
                TAILQ_INSERT_HEAD(&p->vm_regions, vmr, vm_link);
        } else {
@@ -67,6 +68,9 @@ struct vm_region *create_vmr(struct proc *p, uintptr_t va, size_t len)
                        /* Find a gap that is big enough */
                        if (gap_end - vm_i->vm_end >= len) {
                                vmr = kmem_cache_alloc(vmr_kcache, 0);
+                               if (!vmr)
+                                       panic("EOM!");
+                               memset(vmr, 0, sizeof(struct vm_region));
                                /* if we can put it at va, let's do that.  o/w, put it so it
                                 * fits */
                                if ((gap_end >= va + len) && (va >= vm_i->vm_end))