mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-17 00:41:30 +00:00
DM USB: xHCI: Refine drd code to fix a potential NULL pointer issue.
Refine DM DRD code and modify some logical judgement to avoid potential NULL pointer issue. Signed-off-by: Liang Yang <liang3.yang@intel.com> Reviewed-by: Xiaoguang Wu <xiaoguang.wu@intel.com> Reviewed-by: Shuo Liu <shuo.a.liu@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
parent
7109ab45a6
commit
cebc8d9a01
@ -3504,6 +3504,16 @@ pci_xhci_parse_extcap(struct pci_xhci_vdev *xdev, char *opts)
|
|||||||
} else
|
} else
|
||||||
rc = -2;
|
rc = -2;
|
||||||
|
|
||||||
|
if (((struct pci_xhci_excap *)(xdev->excap_ptr))->start
|
||||||
|
== EXCAP_GROUP_END) {
|
||||||
|
xdev->excap_write = NULL;
|
||||||
|
xdev->excap_ptr = excap_group_dft;
|
||||||
|
xdev->vid = XHCI_PCI_VENDOR_ID_DFLT;
|
||||||
|
xdev->pid = XHCI_PCI_DEVICE_ID_DFLT;
|
||||||
|
UPRINTF(LWRN, "Invalid xhci excap, force set "
|
||||||
|
"default excap\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
errout:
|
errout:
|
||||||
if (rc)
|
if (rc)
|
||||||
printf("USB: fail to set vendor capability, rc=%d\r\n", rc);
|
printf("USB: fail to set vendor capability, rc=%d\r\n", rc);
|
||||||
@ -3685,13 +3695,22 @@ pci_xhci_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||||||
|
|
||||||
pci_xhci_reset(xdev);
|
pci_xhci_reset(xdev);
|
||||||
|
|
||||||
|
/* xdev->excap_ptr should be assigned to global array in which
|
||||||
|
* it need include two items at least and field start must be
|
||||||
|
* ended by EXCAP_GROUP_END at last item.
|
||||||
|
*/
|
||||||
excap = xdev->excap_ptr;
|
excap = xdev->excap_ptr;
|
||||||
xdev->excapoff = excap->start;
|
xdev->excapoff = excap->start;
|
||||||
|
|
||||||
while (excap && excap->start != EXCAP_GROUP_END)
|
if (!excap) {
|
||||||
excap++;
|
UPRINTF(LWRN, "Failed to set xHCI extended capability\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
xdev->regsend = (excap - 1)->end;
|
do {
|
||||||
|
xdev->regsend = excap->end;
|
||||||
|
excap++;
|
||||||
|
} while (excap && excap->start != EXCAP_GROUP_END);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set extended capabilities pointer to be after regsend;
|
* Set extended capabilities pointer to be after regsend;
|
||||||
|
Loading…
Reference in New Issue
Block a user