Received: by 10.213.65.68 with SMTP id h4csp2453223imn; Thu, 5 Apr 2018 15:33:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx49cJfaoiBN94CzZZgUXszI7FSRLssEBxU0TYzd+pDUzbAr2an1kpsTwn4WblqOaKDf8AdGX X-Received: by 2002:a17:902:b40d:: with SMTP id x13-v6mr9009909plr.167.1522967633420; Thu, 05 Apr 2018 15:33:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522967633; cv=none; d=google.com; s=arc-20160816; b=0wkh05dzLMMgraOcrKMp+DouW/Txxx/xJkHQAHvvmtfHdVG5OfJKDogfn1ucPwnHas EDdsUoPNl3ZTPIBDT2H1rsRDIzG+3YWbr9/FclCE2Rga386J6ELb0BJ70kf8BMxNBasD LApgDvGzrhamY8zDOSXvHqi5BKav46jVMYcSxi0dGR8M3qlVG/XU0szt9Cca+WG1ktZA Cm6WnZ66RjKVyVISWzojtdAXx5PVtiwXb4xv4ujp6ZN72PaMDCkWpLCr3HRtErkw78T5 2X4LwJ/DjDlqJBU6mVLLzGHqEIcjCHD5YQN8EpEKS0kMjGVq7qGnMRv+XijsQlu0eyOl Tgjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=qPJu3lljGV7feuRvIZKwrkIRaXsL8rFp6AY219EJFWI=; b=DgN6Z55WLo5ETL3EvUoMU9AhiCuYbK7d49Mwhdc4TCIY4bz7ejYBaO67S6ABQkF0zX /GmGvpEl9kyGAAmOggftvragsi5U2GOiyXonGDr0E0kp0uNjXH0rSmaIFd3xZkiZxCXQ PUd3bkrrXvAaQD/FY7IQ10J5w3+x6lXuR+uhQm+wKtS7ALB/XHf0bgtFjOe15Tiu4i0r mVoobA8CK3L2vNEUxvBKAGSPK+tACMi/6pnBV9ebNDTij573Ls18GHqqUgdn1Z4WxQem /6OQoF+oCBERPRM8YGe/EPyMD/HXoTn0uXuDJ+g0In3Vjyr0Xt+Tz74dI62C0FZKKPZq HdQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u189si6863893pfb.102.2018.04.05.15.33.37; Thu, 05 Apr 2018 15:33:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754168AbeDEWcO (ORCPT + 99 others); Thu, 5 Apr 2018 18:32:14 -0400 Received: from osg.samsung.com ([64.30.133.232]:44870 "EHLO osg.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752666AbeDEWcM (ORCPT ); Thu, 5 Apr 2018 18:32:12 -0400 Received: from localhost (localhost [127.0.0.1]) by osg.samsung.com (Postfix) with ESMTP id 0E41F31124; Thu, 5 Apr 2018 15:32:12 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at dev.s-opensource.com Received: from osg.samsung.com ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xjQ4cbUsdzKQ; Thu, 5 Apr 2018 15:32:11 -0700 (PDT) Received: from localhost.localdomain (c-24-9-64-241.hsd1.co.comcast.net [24.9.64.241]) by osg.samsung.com (Postfix) with ESMTPSA id CFE403111C; Thu, 5 Apr 2018 15:32:10 -0700 (PDT) From: Shuah Khan To: valentina.manea.m@gmail.com, shuah@kernel.org, gregkh@linuxfoundation.org Cc: Shuah Khan , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usbip: vhci_hcd: check rhport before using in vhci_hub_control() Date: Thu, 5 Apr 2018 16:31:49 -0600 Message-Id: <20180405223149.24643-1-shuahkh@osg.samsung.com> X-Mailer: git-send-email 2.14.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Validate !rhport < 0 before using it to access port_status array. Signed-off-by: Shuah Khan --- drivers/usb/usbip/vhci_hcd.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c index 20e3d4609583..d11f3f8dad40 100644 --- a/drivers/usb/usbip/vhci_hcd.c +++ b/drivers/usb/usbip/vhci_hcd.c @@ -354,6 +354,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, usbip_dbg_vhci_rh(" ClearHubFeature\n"); break; case ClearPortFeature: + if (rhport < 0) + goto error; switch (wValue) { case USB_PORT_FEAT_SUSPEND: if (hcd->speed == HCD_USB3) { @@ -511,11 +513,16 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, goto error; } + if (rhport < 0) + goto error; + vhci_hcd->port_status[rhport] |= USB_PORT_STAT_SUSPEND; break; case USB_PORT_FEAT_POWER: usbip_dbg_vhci_rh( " SetPortFeature: USB_PORT_FEAT_POWER\n"); + if (rhport < 0) + goto error; if (hcd->speed == HCD_USB3) vhci_hcd->port_status[rhport] |= USB_SS_PORT_STAT_POWER; else @@ -524,6 +531,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, case USB_PORT_FEAT_BH_PORT_RESET: usbip_dbg_vhci_rh( " SetPortFeature: USB_PORT_FEAT_BH_PORT_RESET\n"); + if (rhport < 0) + goto error; /* Applicable only for USB3.0 hub */ if (hcd->speed != HCD_USB3) { pr_err("USB_PORT_FEAT_BH_PORT_RESET req not " @@ -534,6 +543,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, case USB_PORT_FEAT_RESET: usbip_dbg_vhci_rh( " SetPortFeature: USB_PORT_FEAT_RESET\n"); + if (rhport < 0) + goto error; /* if it's already enabled, disable */ if (hcd->speed == HCD_USB3) { vhci_hcd->port_status[rhport] = 0; @@ -554,6 +565,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, default: usbip_dbg_vhci_rh(" SetPortFeature: default %d\n", wValue); + if (rhport < 0) + goto error; if (hcd->speed == HCD_USB3) { if ((vhci_hcd->port_status[rhport] & USB_SS_PORT_STAT_POWER) != 0) { -- 2.14.1