Skip to content

Commit

Permalink
Merge pull request #1185 from hermit-os/virtio-common_cfg-len
Browse files Browse the repository at this point in the history
fix(virtio/pci): compare capabilities length with proper struct size
  • Loading branch information
mkroening authored May 13, 2024
2 parents 6a028b3 + 79c1329 commit bab22aa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/drivers/net/virtio_pci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl VirtioNetDriver {
}
// Drivers MAY do this check. See Virtio specification v1.1. - 4.1.4.1
if cap.len() < MemLen::from(mem::size_of::<NetDevCfg>()*8) {
if cap.len() < MemLen::from(mem::size_of::<NetDevCfg>()) {
error!("Network config from device {:x}, does not represent actual structure specified by the standard!", cap.dev_id());
return None
}
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/virtio/transport/pci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl PciCap {
}

// Drivers MAY do this check. See Virtio specification v1.1. - 4.1.4.1
if self.length < MemLen::from(mem::size_of::<CommonCfg>() * 8) {
if self.length < MemLen::from(mem::size_of::<CommonCfg>()) {
error!("Common config of with id {}, does not represent actual structure specified by the standard!", self.id);
return None;
}
Expand Down

0 comments on commit bab22aa

Please sign in to comment.