OSDN Git Service

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)
commite5d6a7c6cfae9e714a0e8ff64facd1ac68a784c6
treed64fb0832cbc8798ba198927cf143850e38ad6ac
parente4788edc730a0d2b26e1ae1f08fbb3f635b92dbb
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 85e3990bea49
("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