amd64 pmap: Release PTP reference on leaf ptpage allocation failure

aa3bcaa fixed an edge case invloving mlock() and superpage creation
by creating and inserting a leaf pagetable page for mlock'd superpages.
However, the code does not properly release the reference to the
pagetable page in the error handling path.
This commit fixes the issue by adding calls to 'pmap_abort_ptp'
in the error handling path.

Reported by: alc
Approved by: markj (mentor)
Fixes: aa3bcaa
Differential Revision: https://reviews.freebsd.org/D45577
This commit is contained in:
Bojan Novković 2024-06-13 17:58:49 +02:00
parent 018a361f89
commit b53b21e8f8

View file

@ -7595,10 +7595,13 @@ pmap_enter_pde(pmap_t pmap, vm_offset_t va, pd_entry_t newpde, u_int flags,
if ((newpde & PG_W) != 0 && pmap != kernel_pmap) {
uwptpg = pmap_alloc_pt_page(pmap, pmap_pde_pindex(va),
VM_ALLOC_WIRED);
if (uwptpg == NULL)
if (uwptpg == NULL) {
pmap_abort_ptp(pmap, va, pdpg);
return (KERN_RESOURCE_SHORTAGE);
}
if (pmap_insert_pt_page(pmap, uwptpg, true, false)) {
pmap_free_pt_page(pmap, uwptpg, false);
pmap_abort_ptp(pmap, va, pdpg);
return (KERN_RESOURCE_SHORTAGE);
}