Kernel KVM virtualization development
 help / color / mirror / Atom feed
* [PATCH] vfio/pci: Allow VPD short read
@ 2016-06-01  3:28 Alex Williamson
  0 siblings, 0 replies; only message in thread
From: Alex Williamson @ 2016-06-01  3:28 UTC (permalink / raw)
  To: kvm; +Cc: alex.williamson, linux-kernel

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: 4e1a635552d3 ("vfio/pci: Use kernel VPD access functions")
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 drivers/vfio/pci/vfio_pci_config.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
index 9360140..688691d 100644
--- a/drivers/vfio/pci/vfio_pci_config.c
+++ b/drivers/vfio/pci/vfio_pci_config.c
@@ -749,7 +749,8 @@ static int vfio_vpd_config_write(struct vfio_pci_device *vdev, int pos,
 		if (pci_write_vpd(pdev, addr & ~PCI_VPD_ADDR_F, 4, &data) != 4)
 			return count;
 	} else {
-		if (pci_read_vpd(pdev, addr, 4, &data) != 4)
+		data = 0;
+		if (pci_read_vpd(pdev, addr, 4, &data) < 0)
 			return count;
 		*pdata = cpu_to_le32(data);
 	}

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-06-01  3:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-01  3:28 [PATCH] vfio/pci: Allow VPD short read Alex Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox