Skip to content

Commit ffe4449

Browse files
author
Cody Cutler
committed
fix possible memory leak in deallocuvm
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.
1 parent 91fd347 commit ffe4449

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

vm.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ deallocuvm(pde_t *pgdir, uint oldsz, uint newsz)
266266
for(; a < oldsz; a += PGSIZE){
267267
pte = walkpgdir(pgdir, (char*)a, 0);
268268
if(!pte)
269-
a += (NPTENTRIES - 1) * PGSIZE;
269+
a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE;
270270
else if((*pte & PTE_P) != 0){
271271
pa = PTE_ADDR(*pte);
272272
if(pa == 0)

0 commit comments

Comments
 (0)