Commit e28b4a0b authored by Max Vozeler's avatar Max Vozeler Committed by Greg Kroah-Hartman

staging: usbip: vhci: refuse to enqueue for dead connections

commit 6d212153 upstream.

There can be requests to enqueue URBs while we are shutting
down a connection.
Signed-off-by: default avatarMax Vozeler <max@vozeler.com>
Tested-by: default avatarMark Wehby <MWehby@luxotticaRetail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent b076e706
...@@ -558,6 +558,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, ...@@ -558,6 +558,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
struct device *dev = &urb->dev->dev; struct device *dev = &urb->dev->dev;
int ret = 0; int ret = 0;
unsigned long flags; unsigned long flags;
struct vhci_device *vdev;
usbip_dbg_vhci_hc("enter, usb_hcd %p urb %p mem_flags %d\n", usbip_dbg_vhci_hc("enter, usb_hcd %p urb %p mem_flags %d\n",
hcd, urb, mem_flags); hcd, urb, mem_flags);
...@@ -573,6 +574,18 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, ...@@ -573,6 +574,18 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
return urb->status; return urb->status;
} }
vdev = port_to_vdev(the_controller->pending_port);
/* refuse enqueue for dead connection */
spin_lock(&vdev->ud.lock);
if (vdev->ud.status == VDEV_ST_NULL || vdev->ud.status == VDEV_ST_ERROR) {
usbip_uerr("enqueue for inactive port %d\n", vdev->rhport);
spin_unlock(&vdev->ud.lock);
spin_unlock_irqrestore(&the_controller->lock, flags);
return -ENODEV;
}
spin_unlock(&vdev->ud.lock);
ret = usb_hcd_link_urb_to_ep(hcd, urb); ret = usb_hcd_link_urb_to_ep(hcd, urb);
if (ret) if (ret)
goto no_need_unlink; goto no_need_unlink;
...@@ -591,8 +604,6 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, ...@@ -591,8 +604,6 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
__u8 type = usb_pipetype(urb->pipe); __u8 type = usb_pipetype(urb->pipe);
struct usb_ctrlrequest *ctrlreq = struct usb_ctrlrequest *ctrlreq =
(struct usb_ctrlrequest *) urb->setup_packet; (struct usb_ctrlrequest *) urb->setup_packet;
struct vhci_device *vdev =
port_to_vdev(the_controller->pending_port);
if (type != PIPE_CONTROL || !ctrlreq) { if (type != PIPE_CONTROL || !ctrlreq) {
dev_err(dev, "invalid request to devnum 0\n"); dev_err(dev, "invalid request to devnum 0\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment