Skip to content

Commit

Permalink
fix(virtq/split): return id with the correct index for the chain head
Browse files Browse the repository at this point in the history
The incorrect index was used to iterate over the descriptor chain.
Fixes #1327.
  • Loading branch information
cagatay-y committed Jul 22, 2024
1 parent 979e9e0 commit b496e9b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/drivers/virtio/virtqueue/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,11 @@ impl DescrRing {
// need to move [Self::used_ring_ref] lines into a separate scope.
loop {
let used_elem;
let cur_ring_index;
{
if self.read_idx == self.used_ring().idx.to_ne() {
break;
} else {
cur_ring_index = self.read_idx as usize % self.token_ring.len();
let cur_ring_index = self.read_idx as usize % self.token_ring.len();
used_elem = self.used_ring().ring()[cur_ring_index];
}
}
Expand All @@ -184,7 +183,7 @@ impl DescrRing {
queue.try_send(tkn.buff_tkn).unwrap()
}

let mut id_ret_idx = u16::try_from(cur_ring_index).unwrap();
let mut id_ret_idx = u16::try_from(used_elem.id.to_ne()).unwrap();
loop {
self.mem_pool.ret_id(super::MemDescrId(id_ret_idx));
let cur_chain_elem =
Expand Down

0 comments on commit b496e9b

Please sign in to comment.