]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Sep 2021 11:42:14 +0000 (13:42 +0200)
commiteb38ac7ad2809a8cf629bec68780d9666c9ce637
tree793233ccbce4450e23de27cb108da10cd0cf73dd
parent02e838963fdaa6ce8570b5389aecdc6cf1fb40b0
usb: chipidea: host: fix port index underflow and UBSAN complains

[ Upstream commit e5d6a7c6cfae9e714a0e8ff64facd1ac68a784c6 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/chipidea/host.c