Skip to content

Commit 859b0b4

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 <[email protected]>
1 parent cf248db commit 859b0b4

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
@@ -482,8 +482,9 @@ impl GuestMemoryExtension for GuestMemoryMmap {
482482

483483
/// Convert guest physical address to file offset
484484
fn gpa_to_offset(&self, gpa: GuestAddress) -> Option<u64> {
485-
self.find_region(gpa).map(|r| {
486-
gpa.0 - r.start_addr().0 + r.file_offset().expect("File offset is None").start()
485+
self.find_region(gpa).and_then(|r| {
486+
r.file_offset()
487+
.map(|file_offset| gpa.0 - r.start_addr().0 + file_offset.start())
487488
})
488489
}
489490

0 commit comments

Comments
 (0)