mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-22 10:31:08 +00:00
USB: ehci_brcm_hub_control: Improve port index sanitizing
[ Upstream commit 9933698f61
]
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>
This commit is contained in:
parent
432acc8ad2
commit
7171e60715
1 changed files with 5 additions and 1 deletions
|
@ -62,8 +62,12 @@ static int ehci_brcm_hub_control(
|
||||||
u32 __iomem *status_reg;
|
u32 __iomem *status_reg;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int retval, irq_disabled = 0;
|
int retval, irq_disabled = 0;
|
||||||
|
u32 temp;
|
||||||
|
|
||||||
status_reg = &ehci->regs->port_status[(wIndex & 0xff) - 1];
|
temp = (wIndex & 0xff) - 1;
|
||||||
|
if (temp >= HCS_N_PORTS_MAX) /* Avoid index-out-of-bounds warning */
|
||||||
|
temp = 0;
|
||||||
|
status_reg = &ehci->regs->port_status[temp];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RESUME is cleared when GetPortStatus() is called 20ms after start
|
* RESUME is cleared when GetPortStatus() is called 20ms after start
|
||||||
|
|
Loading…
Reference in a new issue