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:
+1
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user