From: Max Vozeler <max@vozeler.com>
To: gregkh@suse.de
Cc: hirofuchi@users.sourceforge.net, rpjday@crashcourse.ca,
bgmerrell@novell.com, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org, mwehby@luxotticaRetail.com,
marco@optikam.com, Max Vozeler <max@vozeler.com>
Subject: [PATCH 4/7] staging: usbip: vhci: refuse to enqueue for dead connections
Date: Wed, 12 Jan 2011 15:02:02 +0200 [thread overview]
Message-ID: <1294837325-26187-5-git-send-email-max@vozeler.com> (raw)
In-Reply-To: <1294837325-26187-1-git-send-email-max@vozeler.com>
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>
---
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 3a22f65..22b1ad9 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,
struct device *dev = &urb->dev->dev;
int ret = 0;
unsigned long flags;
+ struct vhci_device *vdev;
usbip_dbg_vhci_hc("enter, usb_hcd %p urb %p mem_flags %d\n",
hcd, urb, mem_flags);
@@ -574,6 +575,18 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
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);
if (ret)
goto no_need_unlink;
@@ -592,8 +605,6 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
__u8 type = usb_pipetype(urb->pipe);
struct usb_ctrlrequest *ctrlreq =
(struct usb_ctrlrequest *) urb->setup_packet;
- struct vhci_device *vdev =
- port_to_vdev(the_controller->pending_port);
if (type != PIPE_CONTROL || !ctrlreq) {
dev_err(dev, "invalid request to devnum 0\n");
--
1.7.2.3
next prev parent reply other threads:[~2011-01-12 13:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-12 13:01 [PATCH 0/7] staging/usbip fixes Max Vozeler
2011-01-12 13:01 ` [PATCH 1/7] staging: usbip: stub: update refcounts for devices and interfaces Max Vozeler
2011-01-12 13:02 ` [PATCH 2/7] staging: usbip: vhci: update reference count for usb_device Max Vozeler
2011-01-12 13:02 ` [PATCH 3/7] staging: usbip: vhci: give back URBs from in-flight unlink requests Max Vozeler
2011-01-12 13:02 ` Max Vozeler [this message]
2011-01-12 13:02 ` [PATCH 5/7] staging: usbip: vhci: friendly log messages for connection errors Max Vozeler
2011-01-12 13:02 ` [PATCH 6/7] staging: usbip: vhci: handle EAGAIN from SO_RCVTIMEO Max Vozeler
2011-01-12 13:02 ` [PATCH 7/7] staging: usbip: vhci: use urb->dev->portnum to find port Max Vozeler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1294837325-26187-5-git-send-email-max@vozeler.com \
--to=max@vozeler.com \
--cc=bgmerrell@novell.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@suse.de \
--cc=hirofuchi@users.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=marco@optikam.com \
--cc=mwehby@luxotticaRetail.com \
--cc=rpjday@crashcourse.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®