Skip to content

Commit

Permalink
usb: xhci-mtk: fix issue of out-of-bounds array access
Browse files Browse the repository at this point in the history
commit de5107f upstream.

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: 7c986fb ("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>
  • Loading branch information
Chunfeng Yun authored and gregkh committed Sep 12, 2021
1 parent 5b01f30 commit 3cdae99
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/usb/host/xhci-mtk-sch.c
Expand Up @@ -590,10 +590,12 @@ static u32 get_esit_boundary(struct mu3h_sch_ep_info *sch_ep)
u32 boundary = sch_ep->esit;

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

Expand Down

0 comments on commit 3cdae99

Please sign in to comment.