USB: ehci_brcm_hub_control: Improve port index sanitizing
authorHaimin Zhang <tcs.kernel@gmail.com>
Sat, 13 Nov 2021 16:53:20 +0000 (11:53 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 10:04:26 +0000 (11:04 +0100)
commit7171e60715a695f4c62c434e6df94b38965de3ec
tree0f456334ae7430402c092e2635f97ba501217a4f
parent432acc8ad2443807d59c51acf5058a1f14b55566
USB: ehci_brcm_hub_control: Improve port index sanitizing

[ Upstream commit 9933698f6119886c110750e67c10ac66f12b730f ]

Due to (wIndex & 0xff) - 1 can get an integer greater than 15, this
can cause array index to be out of bounds since the size of array
port_status is 15. This change prevents a possible out-of-bounds
pointer computation by forcing the use of a valid port number.

Reported-by: TCS Robot <tcs_robot@tencent.com>
Signed-off-by: Haimin Zhang <tcs.kernel@gmail.com>
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20211113165320.GA59686@rowland.harvard.edu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/host/ehci-brcm.c