fix a potential memory leak

This commit is contained in:
Robert Morris 2019-10-27 13:36:46 -04:00
parent d9160fb4b9
commit e7ffb74ad1
2 changed files with 3 additions and 3 deletions

View file

@ -176,8 +176,7 @@ proc_freepagetable(pagetable_t pagetable, uint64 sz)
{
uvmunmap(pagetable, TRAMPOLINE, PGSIZE, 0);
uvmunmap(pagetable, TRAPFRAME, PGSIZE, 0);
if(sz > 0)
uvmfree(pagetable, sz);
uvmfree(pagetable, sz);
}
// a user program that calls exec("/init")

View file

@ -301,7 +301,8 @@ freewalk(pagetable_t pagetable)
void
uvmfree(pagetable_t pagetable, uint64 sz)
{
uvmunmap(pagetable, 0, sz, 1);
if(sz > 0)
uvmunmap(pagetable, 0, sz, 1);
freewalk(pagetable);
}