Skip to content

Commit

Permalink
usb: xhci-mtk: check boundary before check tt
Browse files Browse the repository at this point in the history
check_sch_tt() will access fs_bus_bw[] array, check boundary
firstly to avoid out-of-bounds issue.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/1629189389-18779-7-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Chunfeng Yun authored and Greg Kroah-Hartman committed Aug 26, 2021
1 parent 451d391 commit 614c8c6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/usb/host/xhci-mtk-sch.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,13 +600,14 @@ static int check_sch_bw(struct mu3h_sch_bw_info *sch_bw,
* and find a microframe where its worst bandwidth is minimum.
*/
for (offset = 0; offset < sch_ep->esit; offset++) {
ret = check_sch_tt(sch_ep, offset);
if (ret)
continue;

if ((offset + sch_ep->num_budget_microframes) > esit_boundary)
break;

ret = check_sch_tt(sch_ep, offset);
if (ret)
continue;

worst_bw = get_max_bw(sch_bw, sch_ep, offset);
if (worst_bw > bw_boundary)
continue;
Expand Down

0 comments on commit 614c8c6

Please sign in to comment.