Skip to content

Commit 15fa6ad

Browse files
committed
fix(vmm): do not unwrap in gpa_to_offset
Return None if file_offset() is None instead. Signed-off-by: Nikita Kalyazin <kalyazin@amazon.com>
1 parent 0a466e9 commit 15fa6ad

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/vmm/src/vstate/memory.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,8 +975,9 @@ impl GuestMemoryExtension for GuestMemoryMmap {
975975

976976
/// Convert guest physical address to file offset
977977
fn gpa_to_offset(&self, gpa: GuestAddress) -> Option<u64> {
978-
self.find_region(gpa).map(|r| {
979-
gpa.0 - r.start_addr().0 + r.file_offset().expect("File offset is None").start()
978+
self.find_region(gpa).and_then(|r| {
979+
r.file_offset()
980+
.map(|file_offset| gpa.0 - r.start_addr().0 + file_offset.start())
980981
})
981982
}
982983

0 commit comments

Comments
 (0)