Skip to content

Commit 85b8266

Browse files
authored
Merge pull request #1986 from cagatay-y/fix-common-cfg-size
fix(virtio): don't include optional fields in minimum size
2 parents 0e904b3 + d365524 commit 85b8266

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • src/drivers/virtio/transport

src/drivers/virtio/transport/pci.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ impl PciCap {
123123
return None;
124124
}
125125

126-
// Drivers MAY do this check. See Virtio specification v1.1. - 4.1.4.1
127-
if self.len() < u64::try_from(mem::size_of::<CommonCfg>()).unwrap() {
126+
// `CommonCfg::queue_notify_data` and `CommonCfg::queue_reset` are optional.
127+
const MIN_SIZE: usize = mem::size_of::<CommonCfg>() - mem::size_of::<[le16; 2]>();
128+
if self.len() < u64::try_from(MIN_SIZE).unwrap() {
128129
error!(
129130
"Common config of with id {}, does not represent actual structure specified by the standard!",
130131
self.cap.id

0 commit comments

Comments
 (0)