From 6acf1b54b497eae8da713aed5816b574c0f4bdfe Mon Sep 17 00:00:00 2001 From: Xiaoguang Wu Date: Tue, 20 Nov 2018 16:14:17 +0800 Subject: [PATCH] DM USB: xHCI: fix potential NULL pointer issue. During S3 process, the dev in the function pci_xhci_device_doorbell may be set to NULL when disconnection is detected by DM. This patch is used to remove this risk. Tracked-On: #1893 Signed-off-by: Xiaoguang Wu --- 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 39373e502..cdb1768c6 100644 --- a/devicemodel/hw/pci/xhci.c +++ b/devicemodel/hw/pci/xhci.c @@ -2929,6 +2929,9 @@ pci_xhci_device_doorbell(struct pci_xhci_vdev *xdev, } dev = XHCI_SLOTDEV_PTR(xdev, slot); + if (!dev) + return; + devep = &dev->eps[epid]; dev_ctx = pci_xhci_get_dev_ctx(xdev, slot); if (!dev_ctx)