UPSTREAM: usb: xhci-mtk: fix issue of out-of-bounds array access

Bus bandwidth array access is based on esit, increase one
will cause out-of-bounds issue; for example, when esit is
XHCI_MTK_MAX_ESIT, will overstep boundary.

Fixes: 7c986fbc16ae ("usb: xhci-mtk: get the microframe boundary for ESIT")
Cc: <stable@vger.kernel.org>
Reported-by: Stan Lu <stan.lu@mediatek.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/1629189389-18779-5-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit de5107f473190538a65aac7edea85209cd5c1a8f)
Bug: 187129171
Signed-off-by: Connor O'Brien <connoro@google.com>
Change-Id: I9e33b02335228e9080828be8c7b189aae6e390c8
This commit is contained in:
Chunfeng Yun
2021-08-17 16:36:25 +08:00
committed by Connor O'Brien
parent 900c38d4ed
commit afb9df4c90

View File

@@ -590,10 +590,12 @@ static u32 get_esit_boundary(struct mu3h_sch_ep_info *sch_ep)
u32 boundary = sch_ep->esit; u32 boundary = sch_ep->esit;
if (sch_ep->sch_tt) { /* LS/FS with TT */ if (sch_ep->sch_tt) { /* LS/FS with TT */
/* tune for CS */ /*
if (sch_ep->ep_type != ISOC_OUT_EP) * tune for CS, normally esit >= 8 for FS/LS,
boundary++; * not add one for other types to avoid access array
else if (boundary > 1) /* normally esit >= 8 for FS/LS */ * out of boundary
*/
if (sch_ep->ep_type == ISOC_OUT_EP && boundary > 1)
boundary--; boundary--;
} }