dm: array bound checking to avoid buffer overflow

The array index of "epid" may be out of bounds if
"epid >= XHCI_MAX_ENDPOINTS", so bound check is
necessary before it is used.

Tracked-On: #3434
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
This commit is contained in:
Tianhua Sun 2019-07-17 16:39:48 +08:00 committed by ACRN System Integration
parent 493ddefd47
commit 107c406baa

View File

@ -3718,6 +3718,8 @@ pci_xhci_dev_intr(struct usb_hci *hci, int epctx)
/* HW endpoint contexts are 0-15; convert to epid based on dir */
epid = (epid * 2) + (dir_in ? 1 : 0);
if (epid >= XHCI_MAX_ENDPOINTS)
return 0;
dev = hci->dev;
xdev = dev->xdev;