[V2 2/2] DM: Add endpoint index value check in doorbell write


Long Liu
 

Add the endpint index value check in doorbell write function,
because the max index value is 32.

Signed-off-by: Liu Long <long.liu@...>
---
devicemodel/hw/pci/xhci.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/devicemodel/hw/pci/xhci.c b/devicemodel/hw/pci/xhci.c
index b5c1365ce..eef4dee4a 100644
--- a/devicemodel/hw/pci/xhci.c
+++ b/devicemodel/hw/pci/xhci.c
@@ -3419,6 +3419,10 @@ pci_xhci_dbregs_write(struct pci_xhci_vdev *xdev,
UPRINTF(LWRN, "pci_xhci: controller halted\r\n");
return;
}
+ if (XHCI_DB_TARGET_GET(value) > XHCI_MAX_ENDPOINTS) {
+ UPRINTF(LWRN, "pci_xhci: endpoint index is not valid.\r\n");
+ return;
+ }

if (offset == 0)
pci_xhci_complete_commands(xdev);
--
2.25.1

Join acrn-dev@lists.projectacrn.org to automatically receive all group messages.