From 691080c73bb4028e3cedca488340bb82417b528d Mon Sep 17 00:00:00 2001 From: "Peter H. Froehlich" Date: Sun, 18 Oct 2015 01:16:17 -0400 Subject: [PATCH] Two sanity checks that were missing. --- main.c | 3 ++- vm.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index c958e51..88a3867 100644 --- a/main.c +++ b/main.c @@ -84,7 +84,8 @@ startothers(void) // Tell entryother.S what stack to use, where to enter, and what // pgdir to use. We cannot use kpgdir yet, because the AP processor // is running in low memory, so we use entrypgdir for the APs too. - stack = kalloc(); + if((stack = kalloc()) == 0) + panic("startothers: failed to allocate stack"); *(void**)(code-4) = stack + KSTACKSIZE; *(void**)(code-8) = mpenter; *(int**)(code-12) = (void *) V2P(entrypgdir); diff --git a/vm.c b/vm.c index 8f34f58..b340696 100644 --- a/vm.c +++ b/vm.c @@ -133,8 +133,8 @@ setupkvm(void) if((pgdir = (pde_t*)kalloc()) == 0) return 0; memset(pgdir, 0, PGSIZE); - if (P2V(PHYSTOP) > (void*)DEVSPACE) - panic("PHYSTOP too high"); + if(P2V(PHYSTOP) > (void*)DEVSPACE) + panic("setupkvm: PHYSTOP too high"); for(k = kmap; k < &kmap[NELEM(kmap)]; k++) if(mappages(pgdir, k->virt, k->phys_end - k->phys_start, (uint)k->phys_start, k->perm) < 0) @@ -148,6 +148,8 @@ void kvmalloc(void) { kpgdir = setupkvm(); + if(kpgdir == 0) + panic("kvmalloc: could not create kernel page table"); switchkvm(); } -- 2.50.1