summaryrefslogtreecommitdiff
path: root/drivers/staging/usbip
diff options
context:
space:
mode:
authorValentina Manea <valentina.manea.m@gmail.com>2014-03-08 12:53:34 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-03-09 06:48:43 (GMT)
commit6080cd0e9239469524d2aa07250ad4b9f383960d (patch)
tree0682e223b8d1345188251e6dd6b05fc1fb4f63c6 /drivers/staging/usbip
parenta46034ca57ed6bdbb574a46ca3453061946b62f9 (diff)
downloadlinux-6080cd0e9239469524d2aa07250ad4b9f383960d.tar.xz
staging: usbip: claim ports used by shared devices
A device should not be able to be used concurrently both by the server and the client. Claiming the port used by the shared device ensures no interface drivers bind to it and that it is not usable from the server. Signed-off-by: Valentina Manea <valentina.manea.m@gmail.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/usbip')
-rw-r--r--drivers/staging/usbip/stub_dev.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index ee899f0..952743c 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -339,6 +339,7 @@ static int stub_probe(struct usb_device *udev)
const char *udev_busid = dev_name(&udev->dev);
int err = 0;
struct bus_id_priv *busid_priv;
+ int rc;
dev_dbg(&udev->dev, "Enter\n");
@@ -388,6 +389,18 @@ static int stub_probe(struct usb_device *udev)
busid_priv->sdev = sdev;
busid_priv->udev = udev;
+ /*
+ * Claim this hub port.
+ * It doesn't matter what value we pass as owner
+ * (struct dev_state) as long as it is unique.
+ */
+ rc = usb_hub_claim_port(udev->parent, udev->portnum,
+ (struct dev_state *) udev);
+ if (rc) {
+ dev_dbg(&udev->dev, "unable to claim port\n");
+ return rc;
+ }
+
err = stub_add_files(&udev->dev);
if (err) {
dev_err(&udev->dev, "stub_add_files for %s\n", udev_busid);
@@ -424,6 +437,7 @@ static void stub_disconnect(struct usb_device *udev)
struct stub_device *sdev;
const char *udev_busid = dev_name(&udev->dev);
struct bus_id_priv *busid_priv;
+ int rc;
dev_dbg(&udev->dev, "Enter\n");
@@ -448,6 +462,14 @@ static void stub_disconnect(struct usb_device *udev)
*/
stub_remove_files(&udev->dev);
+ /* release port */
+ rc = usb_hub_release_port(udev->parent, udev->portnum,
+ (struct dev_state *) udev);
+ if (rc) {
+ dev_dbg(&udev->dev, "unable to release port\n");
+ return;
+ }
+
/* If usb reset is called from event handler */
if (busid_priv->sdev->ud.eh == current)
return;