Skip to content

Commit 6df7337

Browse files
committed
virtio: skip redundant memory check
1 parent 9fccf02 commit 6df7337

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/vmm/src/devices/virtio/queue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ impl<'a, M: GuestMemory> DescriptorChain<'a, M> {
106106
return None;
107107
}
108108

109-
let desc_head = mem.checked_offset(desc_table, (index as usize) * 16)?;
110-
mem.checked_offset(desc_head, 16)?;
109+
// There's no need for checking as we already validated the descriptor table and index bounds.
110+
let desc_head = desc_table.unchecked_add((index as usize) * 16);
111111

112112
// These reads can't fail unless Guest memory is hopelessly broken.
113113
let desc = match mem.read_obj::<Descriptor>(desc_head) {

0 commit comments

Comments
 (0)