diff --git a/usr.sbin/bhyve/pci_xhci.c b/usr.sbin/bhyve/pci_xhci.c --- a/usr.sbin/bhyve/pci_xhci.c +++ b/usr.sbin/bhyve/pci_xhci.c @@ -2706,7 +2706,7 @@ static int pci_xhci_parse_devices(struct pci_xhci_softc *sc, nvlist_t *nvl) { - struct pci_xhci_dev_emu *dev; + struct pci_xhci_dev_emu *dev, **devices, **slots; struct usb_devemu *ue; const nvlist_t *slots_nvl, *slot_nvl; const char *name, *device; @@ -2718,12 +2718,12 @@ usb3_port = sc->usb3_port_start; usb2_port = sc->usb2_port_start; - sc->devices = calloc(XHCI_MAX_DEVS, sizeof(struct pci_xhci_dev_emu *)); - sc->slots = calloc(XHCI_MAX_SLOTS, sizeof(struct pci_xhci_dev_emu *)); + devices = calloc(XHCI_MAX_DEVS, sizeof(struct pci_xhci_dev_emu *)); + slots = calloc(XHCI_MAX_SLOTS, sizeof(struct pci_xhci_dev_emu *)); /* port and slot numbering start from 1 */ - sc->devices--; - sc->slots--; + sc->devices = devices - 1; + sc->slots = slots - 1; ndevices = 0; @@ -2834,8 +2834,8 @@ free(XHCI_DEVINST_PTR(sc, i)); } - free(sc->devices + 1); - free(sc->slots + 1); + free(devices); + free(slots); return (-1); }