Fix similar leak in copyuvm
This commit is contained in:
parent
dd645ef119
commit
ba04b3e70e
1 changed files with 6 additions and 2 deletions
8
vm.c
8
vm.c
|
@ -313,13 +313,17 @@ copyuvm(pde_t *pgdir, uint sz)
|
|||
if(*pte & PTE_P){
|
||||
pa = PTE_ADDR(*pte);
|
||||
if (!(mem = kalloc()))
|
||||
return 0;
|
||||
goto bad;
|
||||
memmove(mem, (char *)pa, PGSIZE);
|
||||
if (!mappages(d, (void *)i, PGSIZE, PADDR(mem), PTE_W|PTE_U))
|
||||
return 0;
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
return d;
|
||||
|
||||
bad:
|
||||
freevm(d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Allocate one page table for the machine for the kernel address
|
||||
|
|
Loading…
Reference in a new issue