mvadkert / rpms / qemu

Forked from rpms/qemu 6 years ago
Clone
1ffd272
From dbd558869cab190a75e33a267d22a7fb7ef78a5f Mon Sep 17 00:00:00 2001
1b1995d
From: Hans de Goede <hdegoede@redhat.com>
1b1995d
Date: Sat, 18 Feb 2012 09:18:57 +0100
1ffd272
Subject: [PATCH] usb-redir: Always clear device state on filter reject
1b1995d
1b1995d
Always call usbredir_device_disconnect() when usbredir_check_filter() fails
1b1995d
to clean up all the device state (ie received endpoint info).
1b1995d
1b1995d
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1b1995d
---
1ffd272
 usb-redir.c | 11 +++++++----
1b1995d
 1 file changed, 7 insertions(+), 4 deletions(-)
1b1995d
1b1995d
diff --git a/usb-redir.c b/usb-redir.c
1ffd272
index d64182b..eb174f0 100644
1b1995d
--- a/usb-redir.c
1b1995d
+++ b/usb-redir.c
1ffd272
@@ -984,7 +984,7 @@ static int usbredir_check_filter(USBRedirDevice *dev)
1b1995d
 {
1b1995d
     if (dev->interface_info.interface_count == 0) {
1b1995d
         ERROR("No interface info for device\n");
1b1995d
-        return -1;
1b1995d
+        goto error;
1b1995d
     }
1b1995d
 
1b1995d
     if (dev->filter_rules) {
1ffd272
@@ -992,7 +992,7 @@ static int usbredir_check_filter(USBRedirDevice *dev)
1b1995d
                                     usb_redir_cap_connect_device_version)) {
1b1995d
             ERROR("Device filter specified and peer does not have the "
1b1995d
                   "connect_device_version capability\n");
1b1995d
-            return -1;
1b1995d
+            goto error;
1b1995d
         }
1b1995d
 
1b1995d
         if (usbredirfilter_check(
1ffd272
@@ -1009,11 +1009,15 @@ static int usbredir_check_filter(USBRedirDevice *dev)
1b1995d
                 dev->device_info.product_id,
1b1995d
                 dev->device_info.device_version_bcd,
1b1995d
                 0) != 0) {
1b1995d
-            return -1;
1b1995d
+            goto error;
1b1995d
         }
1b1995d
     }
1b1995d
 
1b1995d
     return 0;
1b1995d
+
1b1995d
+error:
1b1995d
+    usbredir_device_disconnect(dev);
1b1995d
+    return -1;
1b1995d
 }
1b1995d
 
1b1995d
 /*
1ffd272
@@ -1139,7 +1143,6 @@ static void usbredir_interface_info(void *priv,
1b1995d
         if (usbredir_check_filter(dev)) {
1b1995d
             ERROR("Device no longer matches filter after interface info "
1b1995d
                   "change, disconnecting!\n");
1b1995d
-            usbredir_device_disconnect(dev);
1b1995d
         }
1b1995d
     }
1b1995d
 }