Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa355f60 authored by Maya Erez's avatar Maya Erez
Browse files

usb: host: Fix array access to a non verified index



Fix code quality issues found by the automatic checking tool,
that can cause out of bound access to the port_status and hostpc arrays.
Verify wIndex before accessing the arrays in this index.

Change-Id: Iec7b7b6b66a318e4e97b23ce243e7a128dbf795a
CRs-Fixed: 566927
Signed-off-by: default avatarDanny Segal <dsegal@codeaurora.org>
Signed-off-by: default avatarMaya Erez <merez@codeaurora.org>
parent c5b954d0
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -881,14 +881,19 @@ static int ehci_hub_control (
) {
	struct ehci_hcd	*ehci = hcd_to_ehci (hcd);
	int		ports = HCS_N_PORTS (ehci->hcs_params);
	u32 __iomem	*status_reg = &ehci->regs->port_status[
				(wIndex & 0xff) - 1];
	u32 __iomem	*hostpc_reg = &ehci->regs->hostpc[(wIndex & 0xff) - 1];
	u32 __iomem	*status_reg;
	u32 __iomem	*hostpc_reg;
	u32		temp, temp1, status;
	unsigned long	flags;
	int		retval = 0;
	unsigned	selector;

	if ((wIndex & 0xff) == 0x0)
		return -EINVAL;

	status_reg = &ehci->regs->port_status[(wIndex & 0xff) - 1];
	hostpc_reg = &ehci->regs->hostpc[(wIndex & 0xff) - 1];

	/*
	 * FIXME:  support SetPortFeatures USB_PORT_FEAT_INDICATOR.
	 * HCS_INDICATOR may say we can change LEDs to off/amber/green.