kern: fix resource leak bugs

This commit is contained in:
Michael Scire 2020-07-23 19:26:46 -07:00 committed by SciresM
parent 11d5353827
commit 46935fea80
4 changed files with 7 additions and 2 deletions

View file

@ -75,6 +75,9 @@ namespace ams::kern {
KPageGroup pg(page_table->GetBlockInfoManager());
R_TRY(page_table->LockForDeviceAddressSpace(std::addressof(pg), process_address, size, ConvertToKMemoryPermission(device_perm), is_aligned));
/* Close the pages we opened when we're done with them. */
ON_SCOPE_EXIT { pg.Close(); };
/* Ensure that if we fail, we don't keep unmapped pages locked. */
ON_SCOPE_EXIT {
if (*out_mapped_size != size) {