]> git.baikalelectronics.ru Git - kernel.git/commit
usb: chipidea: host: fix port index underflow and UBSAN complains
authorLi Jun <jun.li@nxp.com>
Fri, 18 Jun 2021 08:28:58 +0000 (16:28 +0800)
committerPeter Chen <peter.chen@kernel.org>
Sat, 21 Aug 2021 05:15:25 +0000 (13:15 +0800)
commitf0887247383fb00b7b3cf8b0384c4d1297262e66
treed64fb0832cbc8798ba198927cf143850e38ad6ac
parent2fe85bc4091f0aebc329a12d4958dc349b49615a
usb: chipidea: host: fix port index underflow and UBSAN complains

If wIndex is 0 (and it often is), these calculations underflow and
UBSAN complains, here resolve this by not decrementing the index when
it is equal to 0, this copies the solution from commit 23fe6a41eacd
("USB: EHCI: avoid undefined pointer arithmetic and placate UBSAN")

Reported-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
Link: https://lore.kernel.org/r/1624004938-2399-1-git-send-email-jun.li@nxp.com
Signed-off-by: Peter Chen <peter.chen@kernel.org>
drivers/usb/chipidea/host.c