Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

virtio_serial: check the host to guest buffer nums #244

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/devices/virtio_serial/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,12 @@ impl VirtioSerial {
.borrow_mut()
.pop_used(&mut g2h, &mut h2g)?;

*self.receive_queues_prefill.index_mut(queue_idx / 2) -= h2g.len();
let prefill_num = self.receive_queues_prefill.index_mut(queue_idx / 2);
if *prefill_num < h2g.len() {
return Err(VirtioSerialError::Device);
}
*prefill_num -= h2g.len();

self.receive_data(port_id, &h2g, len)?;
self.fill_port_queue(port_id)?;

Expand Down
Loading