@@ -599,6 +599,18 @@ static void get_pci_address_for_device(GuestPCIAddress *pci,
}
}
+static GuestPCIAddress *get_empty_pci_address(void)
+{
+ GuestPCIAddress *pci = NULL;
+
+ pci = g_malloc0(sizeof(*pci));
+ pci->domain = -1;
+ pci->slot = -1;
+ pci->function = -1;
+ pci->bus = -1;
+ return pci;
+}
+
static GuestPCIAddress *get_pci_info(int number, Error **errp)
{
HDEVINFO dev_info = INVALID_HANDLE_VALUE;
@@ -608,13 +620,7 @@ static GuestPCIAddress *get_pci_info(int number, Error **errp)
SP_DEVICE_INTERFACE_DATA dev_iface_data;
HANDLE dev_file;
int i;
- GuestPCIAddress *pci = NULL;
-
- pci = g_malloc0(sizeof(*pci));
- pci->domain = -1;
- pci->slot = -1;
- pci->function = -1;
- pci->bus = -1;
+ GuestPCIAddress *pci = get_empty_pci_address();
dev_info = SetupDiGetClassDevs(&GUID_DEVINTERFACE_DISK, 0, 0,
DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);