Free pgdir in setupkvm in case of mappages failure
There is a potential memory leak when mappages() fails inside setupkvm(). A call to freevm() is added in this case so as to reclaim the lost mapping pages.
This commit is contained in:
parent
59cdd6c63b
commit
03b3086327
1 changed files with 3 additions and 1 deletions
4
vm.c
4
vm.c
|
@ -137,8 +137,10 @@ setupkvm(void)
|
|||
panic("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)
|
||||
(uint)k->phys_start, k->perm) < 0) {
|
||||
freevm(pgdir);
|
||||
return 0;
|
||||
}
|
||||
return pgdir;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue