Fix buggy assertion in pcid capability parser.

The pcid capability parsing code has an assertion that checks for dword
alignment. Unfortunately, the check was previously checking for
alignment to qwords. This fixes that.

I found this issue by using qemu to emulate adding different pci
devices. I managed to come across a device that had a capability
aligned on dword, but not qword. That exposed the bug.

Signed-off-by: Wren Turkal <wt@penguintechs.org>
This commit is contained in:
Wren Turkal
2020-07-31 21:21:09 -07:00
parent 5021c68cb3
commit 5db50db7a9
+1 -1
View File
@@ -197,7 +197,7 @@ impl Capability {
})
}
unsafe fn parse<R: ConfigReader>(reader: &R, offset: u8) -> Self {
assert_eq!(offset & 0xF8, offset, "capability must be dword aligned");
assert_eq!(offset & 0xFC, offset, "capability must be dword aligned");
let dword = reader.read_u32(u16::from(offset));
let capability_id = (dword & 0xFF) as u8;