]> 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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Sep 2021 10:26:33 +0000 (12:26 +0200)
commit0562608250795a4aa2d166c046b50e57908fd8ad
tree305269e94592284d87d7705f6b9fcb425e276ba4
parent39d8f2bc977f425ff803fa1fffb4cf4579bed9b8
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 3f82d0e43320
("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