|
@@ -144,6 +144,7 @@ static int bind_device(char *busid)
|
|
|
int rc;
|
|
|
struct udev *udev;
|
|
|
struct udev_device *dev;
|
|
|
+ const char *devpath;
|
|
|
|
|
|
/* Check whether the device with this bus ID exists. */
|
|
|
udev = udev_new();
|
|
@@ -152,8 +153,16 @@ static int bind_device(char *busid)
|
|
|
err("device with the specified bus ID does not exist");
|
|
|
return -1;
|
|
|
}
|
|
|
+ devpath = udev_device_get_devpath(dev);
|
|
|
udev_unref(udev);
|
|
|
|
|
|
+ /* If the device is already attached to vhci_hcd - bail out */
|
|
|
+ if (strstr(devpath, USBIP_VHCI_DRV_NAME)) {
|
|
|
+ err("bind loop detected: device: %s is attached to %s\n",
|
|
|
+ devpath, USBIP_VHCI_DRV_NAME);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
rc = unbind_other(busid);
|
|
|
if (rc == UNBIND_ST_FAILED) {
|
|
|
err("could not unbind driver from device on busid %s", busid);
|