From e3fe3da2732682cbb53e79675851ab33c54b7d8b Mon Sep 17 00:00:00 2001 From: Long Liu Date: Tue, 9 Jun 2020 09:37:12 +0800 Subject: [PATCH] DM USB: xHCI: Fix XHCI_GET_SLOT value check issue Fix XHCI_GET_SLOT macro check slot valid function, when the slot value is bigger than XHCI_MAX_SLOT set the slot value to zero. Tracked-On: #4711 Signed-off-by: Long Liu Reviewed-by: Yuan Liu --- devicemodel/hw/pci/xhci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/devicemodel/hw/pci/xhci.c b/devicemodel/hw/pci/xhci.c index cf7485c4b..80b3d7576 100644 --- a/devicemodel/hw/pci/xhci.c +++ b/devicemodel/hw/pci/xhci.c @@ -2523,9 +2523,10 @@ done: return cmderr; } -#define XHCI_GET_SLOT(xdev, trb, slot, cmderr) \ +#define XHCI_GET_SLOT(xdev, trb, slot, cmderr) \ do { \ - slot = (XHCI_TRB_3_SLOT_GET(trb->dwTrb3)) ? 0 : \ + slot = (XHCI_TRB_3_SLOT_GET(trb->dwTrb3) > \ + XHCI_MAX_SLOTS) ? 0 : \ XHCI_TRB_3_SLOT_GET(trb->dwTrb3); \ if (!slot) \ cmderr = XHCI_TRB_ERROR_INVALID; \