Do not leak empty swblk.

In swp_pager_meta_build(), if the requested operation results in
freeing the last swap pointer in the swblk, free the trie node.  Other
swap pager code does not expect to find completely empty swblk.

Reviewed by:	alc, markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2017-09-06 16:18:53 +00:00
parent e4d52dfd1b
commit 85d88d8799
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=323226

View File

@ -1824,6 +1824,21 @@ swp_pager_meta_build(vm_object_t object, vm_pindex_t pindex, daddr_t swapblk)
swp_pager_freeswapspace(sb->d[modpi], 1);
/* Enter block into metadata. */
sb->d[modpi] = swapblk;
/*
* Free the swblk if we end up with the empty page run.
*/
if (swapblk == SWAPBLK_NONE) {
for (i = 0; i < SWAP_META_PAGES; i++) {
if (sb->d[i] != SWAPBLK_NONE)
break;
}
if (i == SWAP_META_PAGES) {
SWAP_PCTRIE_REMOVE(&object->un_pager.swp.swp_blks,
rdpi);
uma_zfree(swblk_zone, sb);
}
}
}
/*