usbip: vhci_hcd: check rhport before using in vhci_hub_control()
commit 5b22f67611
upstream.
Validate !rhport < 0 before using it to access port_status array.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
4abe5b775a
commit
b792b1f7d0
@ -368,6 +368,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
|||||||
usbip_dbg_vhci_rh(" ClearHubFeature\n");
|
usbip_dbg_vhci_rh(" ClearHubFeature\n");
|
||||||
break;
|
break;
|
||||||
case ClearPortFeature:
|
case ClearPortFeature:
|
||||||
|
if (rhport < 0)
|
||||||
|
goto error;
|
||||||
switch (wValue) {
|
switch (wValue) {
|
||||||
case USB_PORT_FEAT_SUSPEND:
|
case USB_PORT_FEAT_SUSPEND:
|
||||||
if (hcd->speed == HCD_USB3) {
|
if (hcd->speed == HCD_USB3) {
|
||||||
@ -525,11 +527,16 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rhport < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
vhci_hcd->port_status[rhport] |= USB_PORT_STAT_SUSPEND;
|
vhci_hcd->port_status[rhport] |= USB_PORT_STAT_SUSPEND;
|
||||||
break;
|
break;
|
||||||
case USB_PORT_FEAT_POWER:
|
case USB_PORT_FEAT_POWER:
|
||||||
usbip_dbg_vhci_rh(
|
usbip_dbg_vhci_rh(
|
||||||
" SetPortFeature: USB_PORT_FEAT_POWER\n");
|
" SetPortFeature: USB_PORT_FEAT_POWER\n");
|
||||||
|
if (rhport < 0)
|
||||||
|
goto error;
|
||||||
if (hcd->speed == HCD_USB3)
|
if (hcd->speed == HCD_USB3)
|
||||||
vhci_hcd->port_status[rhport] |= USB_SS_PORT_STAT_POWER;
|
vhci_hcd->port_status[rhport] |= USB_SS_PORT_STAT_POWER;
|
||||||
else
|
else
|
||||||
@ -538,6 +545,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
|||||||
case USB_PORT_FEAT_BH_PORT_RESET:
|
case USB_PORT_FEAT_BH_PORT_RESET:
|
||||||
usbip_dbg_vhci_rh(
|
usbip_dbg_vhci_rh(
|
||||||
" SetPortFeature: USB_PORT_FEAT_BH_PORT_RESET\n");
|
" SetPortFeature: USB_PORT_FEAT_BH_PORT_RESET\n");
|
||||||
|
if (rhport < 0)
|
||||||
|
goto error;
|
||||||
/* Applicable only for USB3.0 hub */
|
/* Applicable only for USB3.0 hub */
|
||||||
if (hcd->speed != HCD_USB3) {
|
if (hcd->speed != HCD_USB3) {
|
||||||
pr_err("USB_PORT_FEAT_BH_PORT_RESET req not "
|
pr_err("USB_PORT_FEAT_BH_PORT_RESET req not "
|
||||||
@ -548,6 +557,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
|||||||
case USB_PORT_FEAT_RESET:
|
case USB_PORT_FEAT_RESET:
|
||||||
usbip_dbg_vhci_rh(
|
usbip_dbg_vhci_rh(
|
||||||
" SetPortFeature: USB_PORT_FEAT_RESET\n");
|
" SetPortFeature: USB_PORT_FEAT_RESET\n");
|
||||||
|
if (rhport < 0)
|
||||||
|
goto error;
|
||||||
/* if it's already enabled, disable */
|
/* if it's already enabled, disable */
|
||||||
if (hcd->speed == HCD_USB3) {
|
if (hcd->speed == HCD_USB3) {
|
||||||
vhci_hcd->port_status[rhport] = 0;
|
vhci_hcd->port_status[rhport] = 0;
|
||||||
@ -568,6 +579,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
|||||||
default:
|
default:
|
||||||
usbip_dbg_vhci_rh(" SetPortFeature: default %d\n",
|
usbip_dbg_vhci_rh(" SetPortFeature: default %d\n",
|
||||||
wValue);
|
wValue);
|
||||||
|
if (rhport < 0)
|
||||||
|
goto error;
|
||||||
if (hcd->speed == HCD_USB3) {
|
if (hcd->speed == HCD_USB3) {
|
||||||
if ((vhci_hcd->port_status[rhport] &
|
if ((vhci_hcd->port_status[rhport] &
|
||||||
USB_SS_PORT_STAT_POWER) != 0) {
|
USB_SS_PORT_STAT_POWER) != 0) {
|
||||||
|
Reference in New Issue
Block a user