diff options
author | Max Vozeler <max@vozeler.com> | 2011-01-12 08:02:05 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-01-20 19:01:50 -0500 |
commit | 01446ef5af4e8802369bf4d257806e24345a9371 (patch) | |
tree | c9a13a13f343589b79ef83368e017468778ad5f7 | |
parent | bd65f6233f6bc3233e7910752689fe3a45dc2e0c (diff) |
staging: usbip: vhci: use urb->dev->portnum to find port
The access to pending_port was racy when two devices
were being attached at the same time.
Signed-off-by: Max Vozeler <max@vozeler.com>
Tested-by: Mark Wehby <MWehby@luxotticaRetail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/usbip/vhci.h | 3 | ||||
-rw-r--r-- | drivers/staging/usbip/vhci_hcd.c | 4 |
2 files changed, 1 insertions, 6 deletions
diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h index 2cfd00ec1164..afc3b1a71881 100644 --- a/drivers/staging/usbip/vhci.h +++ b/drivers/staging/usbip/vhci.h | |||
@@ -100,9 +100,6 @@ struct vhci_hcd { | |||
100 | * But, the index of this array begins from 0. | 100 | * But, the index of this array begins from 0. |
101 | */ | 101 | */ |
102 | struct vhci_device vdev[VHCI_NPORTS]; | 102 | struct vhci_device vdev[VHCI_NPORTS]; |
103 | |||
104 | /* vhci_device which has not been assiged its address yet */ | ||
105 | int pending_port; | ||
106 | }; | 103 | }; |
107 | 104 | ||
108 | 105 | ||
diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c index 22b1ad9ebd56..a35fe61268de 100644 --- a/drivers/staging/usbip/vhci_hcd.c +++ b/drivers/staging/usbip/vhci_hcd.c | |||
@@ -138,8 +138,6 @@ void rh_port_connect(int rhport, enum usb_device_speed speed) | |||
138 | * the_controller->vdev[rhport].ud.status = VDEV_CONNECT; | 138 | * the_controller->vdev[rhport].ud.status = VDEV_CONNECT; |
139 | * spin_unlock(&the_controller->vdev[rhport].ud.lock); */ | 139 | * spin_unlock(&the_controller->vdev[rhport].ud.lock); */ |
140 | 140 | ||
141 | the_controller->pending_port = rhport; | ||
142 | |||
143 | spin_unlock_irqrestore(&the_controller->lock, flags); | 141 | spin_unlock_irqrestore(&the_controller->lock, flags); |
144 | 142 | ||
145 | usb_hcd_poll_rh_status(vhci_to_hcd(the_controller)); | 143 | usb_hcd_poll_rh_status(vhci_to_hcd(the_controller)); |
@@ -575,7 +573,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, | |||
575 | return urb->status; | 573 | return urb->status; |
576 | } | 574 | } |
577 | 575 | ||
578 | vdev = port_to_vdev(the_controller->pending_port); | 576 | vdev = port_to_vdev(urb->dev->portnum-1); |
579 | 577 | ||
580 | /* refuse enqueue for dead connection */ | 578 | /* refuse enqueue for dead connection */ |
581 | spin_lock(&vdev->ud.lock); | 579 | spin_lock(&vdev->ud.lock); |