When usbredirhost clears the current device, it resets the device and
attempts to re-attach the kernel driver for the device.  The current
device is cleared when the API user explicitly sets a new device with
usbredirhost_set_device().  However, some API users call
usbredirhost_set_device(..., NULL) to clear the current device when the
redirected device has been unplugged.  In this scenario, resetting the
device will fail and print a warning to the terminal. Since this is an
expected scenario, we should simply handle it rather than printing an

Resolves: rhbz#1442963
 usbredirhost/usbredirhost.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/usbredirhost/usbredirhost.c b/usbredirhost/usbredirhost.c
index a6bf8b3..3666227 100644
--- a/usbredirhost/usbredirhost.c
+++ b/usbredirhost/usbredirhost.c
@@ -604,7 +604,11 @@ static void usbredirhost_release(struct usbredirhost 
*host, int attach_drivers)
     if (!(host->quirks & QUIRK_DO_NOT_RESET)) {
         r = libusb_reset_device(host->handle);
         if (r != 0) {
-            ERROR("error resetting device: %s", libusb_error_name(r));
+            /* if we're releasing the device because it was removed, resetting
+             * will fail. Don't print a warning in this situation */
+            if (r != LIBUSB_ERROR_NO_DEVICE) {
+                ERROR("error resetting device: %s", libusb_error_name(r));
+            }

Spice-devel mailing list

Reply via email to