DM: xHCI: Check trb pointer before use it

The trb pointer may be NULL when get the address from user space, add
the pointer check before use the trb.

Tracked-On: #6172
Signed-off-by: Liu Long <long.liu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
Yonghua Huang 2021-07-01 16:14:46 +08:00 committed by wenlingz
parent 2b91780b4e
commit ea76e59d77

View File

@ -2551,6 +2551,10 @@ pci_xhci_complete_commands(struct pci_xhci_vdev *xdev)
trb = xdev->opregs.cr_p;
ccs = xdev->opregs.crcr & XHCI_CRCR_LO_RCS;
crcr = xdev->opregs.crcr & ~0xF;
if (!trb) {
UPRINTF(LDBG, "Get the invalid guest address!\r\n");
goto out;
}
while (1) {
xdev->opregs.cr_p = trb;
@ -2663,6 +2667,7 @@ pci_xhci_complete_commands(struct pci_xhci_vdev *xdev)
trb = pci_xhci_trb_next(xdev, trb, &crcr);
}
out:
xdev->opregs.crcr = crcr | (xdev->opregs.crcr & XHCI_CRCR_LO_CA) | ccs;
xdev->opregs.crcr &= ~XHCI_CRCR_LO_CRR;
return error;