Skip to content

Commit

Permalink
staging: usbip: vhci: use urb->dev->portnum to find port
Browse files Browse the repository at this point in the history
commit 01446ef upstream.

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>
  • Loading branch information
Max Vozeler authored and Greg Kroah-Hartman committed Mar 2, 2011
1 parent e28b4a0 commit e905378
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
3 changes: 0 additions & 3 deletions drivers/staging/usbip/vhci.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ struct vhci_hcd {
* But, the index of this array begins from 0.
*/
struct vhci_device vdev[VHCI_NPORTS];

/* vhci_device which has not been assiged its address yet */
int pending_port;
};


Expand Down
4 changes: 1 addition & 3 deletions drivers/staging/usbip/vhci_hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ void rh_port_connect(int rhport, enum usb_device_speed speed)
* the_controller->vdev[rhport].ud.status = VDEV_CONNECT;
* spin_unlock(&the_controller->vdev[rhport].ud.lock); */

the_controller->pending_port = rhport;

spin_unlock_irqrestore(&the_controller->lock, flags);

usb_hcd_poll_rh_status(vhci_to_hcd(the_controller));
Expand Down Expand Up @@ -574,7 +572,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
return urb->status;
}

vdev = port_to_vdev(the_controller->pending_port);
vdev = port_to_vdev(urb->dev->portnum-1);

/* refuse enqueue for dead connection */
spin_lock(&vdev->ud.lock);
Expand Down

0 comments on commit e905378

Please sign in to comment.