As of r335784, if pmap_enter() replaces a managed mapping by an unmanaged

mapping, then it leaks the unlinked PV entry.  This change eliminates that
leak, freeing the PV entry.

Reviewed by:	kib, markj
X-MFC with:	r335784
Differential Revision:	https://reviews.freebsd.org/D16130
This commit is contained in:
alc 2018-07-05 02:04:18 +00:00
parent 7015e5246c
commit c5f98d1933

View File

@ -4900,6 +4900,8 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot,
vm_page_aflag_set(om, PGA_REFERENCED);
CHANGE_PV_LIST_LOCK_TO_PHYS(&lock, opa);
pv = pmap_pvh_remove(&om->md, pmap, va);
if ((newpte & PG_MANAGED) == 0)
free_pv_entry(pmap, pv);
if ((om->aflags & PGA_WRITEABLE) != 0 &&
TAILQ_EMPTY(&om->md.pv_list) &&
((om->flags & PG_FICTITIOUS) != 0 ||