mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-10 02:54:58 -06:00
pcie_sriov: Ensure VF function number does not overflow
pci_new() aborts when creating a VF with a function number equals to or is greater than PCI_DEVFN_MAX. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Message-Id: <20240627-reuse-v10-5-7ca0b8ed3d9f@daynix.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
c613ad2512
commit
7771870115
5 changed files with 51 additions and 18 deletions
13
hw/net/igb.c
13
hw/net/igb.c
|
@ -446,9 +446,16 @@ static void igb_pci_realize(PCIDevice *pci_dev, Error **errp)
|
|||
|
||||
pcie_ari_init(pci_dev, 0x150);
|
||||
|
||||
pcie_sriov_pf_init(pci_dev, IGB_CAP_SRIOV_OFFSET, TYPE_IGBVF,
|
||||
IGB_82576_VF_DEV_ID, IGB_MAX_VF_FUNCTIONS, IGB_MAX_VF_FUNCTIONS,
|
||||
IGB_VF_OFFSET, IGB_VF_STRIDE);
|
||||
if (!pcie_sriov_pf_init(pci_dev, IGB_CAP_SRIOV_OFFSET,
|
||||
TYPE_IGBVF, IGB_82576_VF_DEV_ID,
|
||||
IGB_MAX_VF_FUNCTIONS, IGB_MAX_VF_FUNCTIONS,
|
||||
IGB_VF_OFFSET, IGB_VF_STRIDE,
|
||||
errp)) {
|
||||
pcie_cap_exit(pci_dev);
|
||||
igb_cleanup_msix(s);
|
||||
msi_uninit(pci_dev);
|
||||
return;
|
||||
}
|
||||
|
||||
pcie_sriov_pf_init_vf_bar(pci_dev, IGBVF_MMIO_BAR_IDX,
|
||||
PCI_BASE_ADDRESS_MEM_TYPE_64 | PCI_BASE_ADDRESS_MEM_PREFETCH,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue