diff options
author | Max Vozeler <max@vozeler.com> | 2011-01-12 08:02:02 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-01-20 19:01:49 -0500 |
commit | 6d212153a838354078cc7d96f9bb23b7d1fd3d1b (patch) | |
tree | 6fe1f8d9fea3b663ec88201f12004c18f3422a3f | |
parent | b92a5e23737172c52656a090977408a80d7f06d1 (diff) |
staging: usbip: vhci: refuse to enqueue for dead connections
There can be requests to enqueue URBs while we are shutting
down a connection.
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_hcd.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c index 3a22f65b66d0..22b1ad9ebd56 100644 --- a/drivers/staging/usbip/vhci_hcd.c +++ b/drivers/staging/usbip/vhci_hcd.c | |||
@@ -559,6 +559,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, | |||
559 | struct device *dev = &urb->dev->dev; | 559 | struct device *dev = &urb->dev->dev; |
560 | int ret = 0; | 560 | int ret = 0; |
561 | unsigned long flags; | 561 | unsigned long flags; |
562 | struct vhci_device *vdev; | ||
562 | 563 | ||
563 | usbip_dbg_vhci_hc("enter, usb_hcd %p urb %p mem_flags %d\n", | 564 | usbip_dbg_vhci_hc("enter, usb_hcd %p urb %p mem_flags %d\n", |
564 | hcd, urb, mem_flags); | 565 | hcd, urb, mem_flags); |
@@ -574,6 +575,18 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, | |||
574 | return urb->status; | 575 | return urb->status; |
575 | } | 576 | } |
576 | 577 | ||
578 | vdev = port_to_vdev(the_controller->pending_port); | ||
579 | |||
580 | /* refuse enqueue for dead connection */ | ||
581 | spin_lock(&vdev->ud.lock); | ||
582 | if (vdev->ud.status == VDEV_ST_NULL || vdev->ud.status == VDEV_ST_ERROR) { | ||
583 | usbip_uerr("enqueue for inactive port %d\n", vdev->rhport); | ||
584 | spin_unlock(&vdev->ud.lock); | ||
585 | spin_unlock_irqrestore(&the_controller->lock, flags); | ||
586 | return -ENODEV; | ||
587 | } | ||
588 | spin_unlock(&vdev->ud.lock); | ||
589 | |||
577 | ret = usb_hcd_link_urb_to_ep(hcd, urb); | 590 | ret = usb_hcd_link_urb_to_ep(hcd, urb); |
578 | if (ret) | 591 | if (ret) |
579 | goto no_need_unlink; | 592 | goto no_need_unlink; |
@@ -592,8 +605,6 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, | |||
592 | __u8 type = usb_pipetype(urb->pipe); | 605 | __u8 type = usb_pipetype(urb->pipe); |
593 | struct usb_ctrlrequest *ctrlreq = | 606 | struct usb_ctrlrequest *ctrlreq = |
594 | (struct usb_ctrlrequest *) urb->setup_packet; | 607 | (struct usb_ctrlrequest *) urb->setup_packet; |
595 | struct vhci_device *vdev = | ||
596 | port_to_vdev(the_controller->pending_port); | ||
597 | 608 | ||
598 | if (type != PIPE_CONTROL || !ctrlreq) { | 609 | if (type != PIPE_CONTROL || !ctrlreq) { |
599 | dev_err(dev, "invalid request to devnum 0\n"); | 610 | dev_err(dev, "invalid request to devnum 0\n"); |