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>

authored by Max Vozeler and committed by Greg Kroah-Hartman 6d212153 b92a5e23

+13 -2
+13 -2
drivers/staging/usbip/vhci_hcd.c
··· 559 559 struct device *dev = &urb->dev->dev; 560 560 int ret = 0; 561 561 unsigned long flags; 562 + struct vhci_device *vdev; 562 563 563 564 usbip_dbg_vhci_hc("enter, usb_hcd %p urb %p mem_flags %d\n", 564 565 hcd, urb, mem_flags); ··· 574 573 spin_unlock_irqrestore(&the_controller->lock, flags); 575 574 return urb->status; 576 575 } 576 + 577 + vdev = port_to_vdev(the_controller->pending_port); 578 + 579 + /* refuse enqueue for dead connection */ 580 + spin_lock(&vdev->ud.lock); 581 + if (vdev->ud.status == VDEV_ST_NULL || vdev->ud.status == VDEV_ST_ERROR) { 582 + usbip_uerr("enqueue for inactive port %d\n", vdev->rhport); 583 + spin_unlock(&vdev->ud.lock); 584 + spin_unlock_irqrestore(&the_controller->lock, flags); 585 + return -ENODEV; 586 + } 587 + spin_unlock(&vdev->ud.lock); 577 588 578 589 ret = usb_hcd_link_urb_to_ep(hcd, urb); 579 590 if (ret) ··· 605 592 __u8 type = usb_pipetype(urb->pipe); 606 593 struct usb_ctrlrequest *ctrlreq = 607 594 (struct usb_ctrlrequest *) urb->setup_packet; 608 - struct vhci_device *vdev = 609 - port_to_vdev(the_controller->pending_port); 610 595 611 596 if (type != PIPE_CONTROL || !ctrlreq) { 612 597 dev_err(dev, "invalid request to devnum 0\n");