xv6-riscv icon indicating copy to clipboard operation
xv6-riscv copied to clipboard

[fix] mappages: potential memory leak

Open yztz opened this issue 2 years ago • 0 comments

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.

yztz avatar Apr 19 '22 03:04 yztz