Skip to content

Commit ce7585f

Browse files
committed
vfio/pci: Allow VPD short read
The size of the VPD area is not necessarily 4-byte aligned, so a pci_vpd_read() might return less than 4 bytes. Zero our buffer and accept anything other than an error. Intel X710 NICs exercise this. Fixes: 4e1a635 ("vfio/pci: Use kernel VPD access functions") Signed-off-by: Alex Williamson <[email protected]>
1 parent 089f1c6 commit ce7585f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/vfio/pci/vfio_pci_config.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,8 @@ static int vfio_vpd_config_write(struct vfio_pci_device *vdev, int pos,
749749
if (pci_write_vpd(pdev, addr & ~PCI_VPD_ADDR_F, 4, &data) != 4)
750750
return count;
751751
} else {
752-
if (pci_read_vpd(pdev, addr, 4, &data) != 4)
752+
data = 0;
753+
if (pci_read_vpd(pdev, addr, 4, &data) < 0)
753754
return count;
754755
*pdata = cpu_to_le32(data);
755756
}

0 commit comments

Comments
 (0)