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:
parent
2cd1fd1145
commit
7b18f5eb6f
@ -535,28 +535,24 @@ int up_addrenv_destroy(arch_addrenv_t *addrenv)
|
|||||||
{
|
{
|
||||||
for (i = 0; i < ENTRIES_PER_PGT; i++, vaddr += pgsize)
|
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]));
|
ptlast = (uintptr_t *)riscv_pgvaddr(mmu_pte_to_paddr(ptprev[i]));
|
||||||
if (ptlast)
|
if (ptlast)
|
||||||
{
|
{
|
||||||
/* Page table allocated, free any allocated memory */
|
if (!vaddr_is_shm(vaddr))
|
||||||
|
|
||||||
for (j = 0; j < ENTRIES_PER_PGT; j++)
|
|
||||||
{
|
{
|
||||||
paddr = mmu_pte_to_paddr(ptlast[j]);
|
/* Free the allocated pages, but not from SHM area */
|
||||||
if (paddr)
|
|
||||||
|
for (j = 0; j < ENTRIES_PER_PGT; j++)
|
||||||
{
|
{
|
||||||
mm_pgfree(paddr, 1);
|
paddr = mmu_pte_to_paddr(ptlast[j]);
|
||||||
|
if (paddr)
|
||||||
|
{
|
||||||
|
mm_pgfree(paddr, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Then free the page table itself */
|
/* Regardless, free the page table itself */
|
||||||
|
|
||||||
mm_pgfree((uintptr_t)ptlast, 1);
|
mm_pgfree((uintptr_t)ptlast, 1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user