Commit 8472cc4503eb ("riscv: mm: call PUD/P4D ctor in special kernel pgtable alloc") made alloc_pud_late() run the PUD page-table constructor. However, free_pud_table() still frees non-reserved PUD tables directly without decrementing NR_PAGETABLE. Free PUD tables through the common free_pagetable() helper so that constructor-backed tables run the matching destructor before being freed. Fixes: 8472cc4503eb ("riscv: mm: call PUD/P4D ctor in special kernel pgtable alloc") Cc: stable@vger.kernel.org Assisted-by: LLM Signed-off-by: Muchun Song --- arch/riscv/mm/init.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 429a0b015ec1..62077539ee78 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -1540,10 +1540,7 @@ static void __meminit free_pud_table(pud_t *pud_start, p4d_t *p4d) return; } - if (PageReserved(page)) - free_reserved_page(page); - else - __free_pages(page, 0); + free_pagetable(page); p4d_clear(p4d); } -- 2.54.0