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.
In mappages, if
size
> 1PAGESIZE
orva
not page-aligned(i.e. need to map more than one page), it will lead to a memory leak with a midwaykalloc
failure. When mappages returns -1, it will try to calluvmfree
->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 1PAGESIZE
, so this problem doesn't rise.