xv6-riscv
xv6-riscv copied to clipboard
[fix] mappages: potential memory leak
In mappages, if size
> 1 * PAGESIZE
or va
not page-aligned(i.e. need to map more than one page), it will lead to a memory leak with a midway kalloc
failure. When mappages returns -1, it will try to call uvmfree
->freewalk
to free the page-table pages and may lead to a panic because of an mapped page.
In the unmodified version, maapages always successes or is only called with 1 * PAGESIZE
, so this problem doesn't rise.