risc-v/riscv_addrenv.c: Fix bug where SHM area page tables are not freed

The SHM physically backed memory does not belong to the user process,
but the page table containing the mapping does -> delete the page table
memory regardless.
This commit is contained in:
Ville Juven 2023-09-27 15:04:59 +03:00 committed by Xiang Xiao
parent 2cd1fd1145
commit 7b18f5eb6f

View File

@ -535,17 +535,12 @@ int up_addrenv_destroy(arch_addrenv_t *addrenv)
{
for (i = 0; i < ENTRIES_PER_PGT; i++, vaddr += pgsize)
{
if (vaddr_is_shm(vaddr))
{
/* Do not free memory from SHM area */
continue;
}
ptlast = (uintptr_t *)riscv_pgvaddr(mmu_pte_to_paddr(ptprev[i]));
if (ptlast)
{
/* Page table allocated, free any allocated memory */
if (!vaddr_is_shm(vaddr))
{
/* Free the allocated pages, but not from SHM area */
for (j = 0; j < ENTRIES_PER_PGT; j++)
{
@ -555,8 +550,9 @@ int up_addrenv_destroy(arch_addrenv_t *addrenv)
mm_pgfree(paddr, 1);
}
}
}
/* Then free the page table itself */
/* Regardless, free the page table itself */
mm_pgfree((uintptr_t)ptlast, 1);
}