diff options
author | Chunfeng Yun <chunfeng.yun@mediatek.com> | 2021-08-17 11:36:27 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-08-26 14:39:20 +0300 |
commit | 614c8c67a071d44be54266b78c21e2a505ac1b32 (patch) | |
tree | e8e1e685f15bf0b6a60bb8f5d14e4d09c9132e74 | |
parent | 451d3912586aad3f71f1c97780a1c21e3de98413 (diff) | |
download | linux-614c8c67a071d44be54266b78c21e2a505ac1b32.tar.xz |
usb: xhci-mtk: check boundary before check tt
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>
-rw-r--r-- | drivers/usb/host/xhci-mtk-sch.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c index 10c0f0f6461f..c2f13d69c607 100644 --- a/drivers/usb/host/xhci-mtk-sch.c +++ b/drivers/usb/host/xhci-mtk-sch.c @@ -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; |