From c2d85b13d6e0fa8d1010d03b402300682413ca54 Mon Sep 17 00:00:00 2001 From: Liu Long Date: Tue, 1 Sep 2020 13:32:35 +0800 Subject: [PATCH] DM: xHCI: Add Null pointer check in Set TR Dequeue command Add Null pointer check in Set TR Dequeue command handle function to avoid Null pointer exception. Fllow xHCI spec 4.6.10, for Set TR Dequeue pointer command, when the slot is not enabled the completion code should be Slot Not Enabled Error. Tracked-On: #5263 Signed-off-by: Long Liu Acked-by: Yu Wang yu1.wang@intel.com --- devicemodel/hw/pci/xhci.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/devicemodel/hw/pci/xhci.c b/devicemodel/hw/pci/xhci.c index fb1e22edc..75623d523 100644 --- a/devicemodel/hw/pci/xhci.c +++ b/devicemodel/hw/pci/xhci.c @@ -2423,6 +2423,11 @@ pci_xhci_cmd_set_tr(struct pci_xhci_vdev *xdev, cmderr = XHCI_TRB_ERROR_SUCCESS; dev = XHCI_SLOTDEV_PTR(xdev, slot); + if (!dev) { + UPRINTF(LDBG, "%s slot is not enabled!\r\n", __func__); + cmderr = XHCI_TRB_ERROR_SLOT_NOT_ON; + goto done; + } UPRINTF(LDBG, "set_tr: new-tr x%016lx, SCT %u DCS %u\r\n" " stream-id %u, slot %u, epid %u, C %u\r\n", (trb->qwTrb0 & ~0xF), (uint32_t)((trb->qwTrb0 >> 1) & 0x7),