Skip to content

Commit d2627ec

Browse files
xiaoguangwuwenlingz
authored andcommitted
DM USB: xHCI: fix an issues for failing to enumerate device
This is an obvious bug, which releases memory but still access the data on the released memory. It is risky operation, and may result failing to do normal enumlation process. This patch is used to fix it. Tracked-On: #1893 Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com> Reviewed-by: Liang Yang <liang3.yang@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
1 parent 1c3344b commit d2627ec

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

devicemodel/hw/pci/xhci.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,8 +1802,6 @@ pci_xhci_cmd_disable_slot(struct pci_xhci_vdev *xdev, uint32_t slot)
18021802
goto done;
18031803
}
18041804

1805-
pci_xhci_dev_destroy(dev);
1806-
18071805
for (j = 0; j < XHCI_MAX_VIRT_PORTS; ++j) {
18081806
path = &xdev->vbdp_devs[j].path;
18091807

@@ -1818,6 +1816,9 @@ pci_xhci_cmd_disable_slot(struct pci_xhci_vdev *xdev, uint32_t slot)
18181816
}
18191817
UPRINTF(LINF, "disable slot %d for native device %d-%s\r\n",
18201818
slot, di->path.bus, usb_dev_path(&di->path));
1819+
1820+
/* release all the resource allocated for virtual device */
1821+
pci_xhci_dev_destroy(dev);
18211822
} else
18221823
UPRINTF(LWRN, "invalid slot %d\r\n", slot);
18231824

0 commit comments

Comments
 (0)