diff --git a/src/node_device/node_device_linux_sysfs.c b/src/node_device/node_device_linux_sysfs.c index 24a6a2eaa5..549d32c4b9 100644 --- a/src/node_device/node_device_linux_sysfs.c +++ b/src/node_device/node_device_linux_sysfs.c @@ -154,19 +154,25 @@ nodeDeviceSysfsGetPCISRIOVCaps(const char *sysfsPath, data->pci_dev.flags &= ~VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION; data->pci_dev.flags &= ~VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION; - if (!virPCIGetPhysicalFunction(sysfsPath, &data->pci_dev.physical_function)) + ret = virPCIGetPhysicalFunction(sysfsPath, + &data->pci_dev.physical_function); + if (ret < 0) + goto cleanup; + + if (data->pci_dev.physical_function) data->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION; ret = virPCIGetVirtualFunctions(sysfsPath, &data->pci_dev.virtual_functions, &data->pci_dev.num_virtual_functions, &data->pci_dev.max_virtual_functions); if (ret < 0) - return ret; + goto cleanup; if (data->pci_dev.num_virtual_functions > 0 || data->pci_dev.max_virtual_functions > 0) data->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION; + cleanup: return ret; } diff --git a/src/util/virpci.c b/src/util/virpci.c index 28da294872..095d7068c2 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -2732,6 +2732,9 @@ virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path, if (virPCIGetPhysicalFunction(vf_sysfs_device_path, &pf_config_address) < 0) return ret; + if (!pf_config_address) + return ret; + if (virPCIDeviceAddressGetSysfsFile(pf_config_address, &pf_sysfs_device_path) < 0) {