From 84c0c87842b99e6c8907132e8978c0ef37878576 Mon Sep 17 00:00:00 2001 From: Liang Yang Date: Fri, 12 Oct 2018 10:24:34 +0800 Subject: [PATCH] DM USB: xHCI: Fix a potential NULL pointer issue. After excap pointer is assigned, it should be checked whether it's possible to get assignment for NULL pointer or not. This patch fixes this issue. Tracked-On: #1479 Signed-off-by: Liang Yang Reviewed-by: Xiaoguang Wu Reviewed-by: Liu Shuo Acked-by: Yu Wang --- devicemodel/hw/pci/xhci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/devicemodel/hw/pci/xhci.c b/devicemodel/hw/pci/xhci.c index fb680e88b..b09b3cb9a 100755 --- a/devicemodel/hw/pci/xhci.c +++ b/devicemodel/hw/pci/xhci.c @@ -4001,13 +4001,13 @@ pci_xhci_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts) * ended by EXCAP_GROUP_END at last item. */ excap = xdev->excap_ptr; - xdev->excapoff = excap->start; - if (!excap) { - UPRINTF(LWRN, "Failed to set xHCI extended capability\r\n"); - return -1; + error = -1; + goto done; } + xdev->excapoff = excap->start; + do { xdev->regsend = excap->end; excap++;