]> Devi Nivas Git - cs3210-lab1.git/commitdiff
fix possible memory leak in deallocuvm
authorCody Cutler <ccutler@csail.mit.edu>
Mon, 26 Sep 2016 16:21:01 +0000 (12:21 -0400)
committerCody Cutler <ccutler@csail.mit.edu>
Mon, 26 Sep 2016 16:34:08 +0000 (12:34 -0400)
when a zero PDE is encountered while searching for present PTEs to free,
resume searching at first entry of the next page table instead of the
current entry of the next page table.

vm.c

diff --git a/vm.c b/vm.c
index d9aaa7ec37dd99b833bfa640975e3303dbfe1645..764512cfec66b11b1d360a72515c57c6a3466e7e 100644 (file)
--- a/vm.c
+++ b/vm.c
@@ -266,7 +266,7 @@ deallocuvm(pde_t *pgdir, uint oldsz, uint newsz)
   for(; a  < oldsz; a += PGSIZE){
     pte = walkpgdir(pgdir, (char*)a, 0);
     if(!pte)
-      a += (NPTENTRIES - 1) * PGSIZE;
+      a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE;
     else if((*pte & PTE_P) != 0){
       pa = PTE_ADDR(*pte);
       if(pa == 0)