From 015de93cc40a3a92b74dbe702935bb1d90f40d16 Mon Sep 17 00:00:00 2001 From: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> Date: Mon, 20 Jul 2026 16:00:41 -0700 Subject: [PATCH] Fix dynamic mapping ownership on unmap failure Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> --- src/hyperlight_host/src/hypervisor/hyperlight_vm/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hyperlight_host/src/hypervisor/hyperlight_vm/mod.rs b/src/hyperlight_host/src/hypervisor/hyperlight_vm/mod.rs index 2e545aba7..b046f070f 100644 --- a/src/hyperlight_host/src/hypervisor/hyperlight_vm/mod.rs +++ b/src/hyperlight_host/src/hypervisor/hyperlight_vm/mod.rs @@ -509,9 +509,10 @@ impl HyperlightVm { .position(|(_, r)| r == region) .ok_or(UnmapRegionError::RegionNotFound)?; - let (slot, _) = self.mmap_regions.remove(pos); - self.freed_slots.push(slot); + let slot = self.mmap_regions[pos].0; self.vm.unmap_memory((slot, region))?; + self.mmap_regions.remove(pos); + self.freed_slots.push(slot); Ok(()) }