From 01c8f546e05284fcd59d368c8f20d7e7d57f96cd Mon Sep 17 00:00:00 2001 From: Tianhua Sun Date: Wed, 2 Jan 2019 13:38:57 +0800 Subject: [PATCH] DM: xHCI: array bound checking before it is used Array index of "vbdp_devs" may be out of bounds if "i >= XHCI_MAX_VIRT_PORTS", so index checking is necessary. Tracked-On: #1252 Signed-off-by: Tianhua Sun Acked-by: Yu Wang --- devicemodel/hw/pci/xhci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/devicemodel/hw/pci/xhci.c b/devicemodel/hw/pci/xhci.c index 34ed3084e0..e20a8c9cb6 100644 --- a/devicemodel/hw/pci/xhci.c +++ b/devicemodel/hw/pci/xhci.c @@ -721,6 +721,9 @@ xhci_vbdp_thread(void *data) break; } + if (i >= XHCI_MAX_VIRT_PORTS) + continue; + j = pci_xhci_get_native_port_index_by_path(xdev, &xdev->vbdp_devs[i].path); if (j < 0)