Re: [spice-gtk Win32 v5 05/22] spice_usb_device_manager_add_dev: check auto_ok before freeing libusb device list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/09/2012 03:54 PM, Marc-André Lureau wrote:
It would have been more sensible to move libusb_free_device_list() to
the end of the function, perhaps (goto cleanup or something).

Although very unlikely, that may cause a race between freeing the list and
opening the specific device after driver installation.


ack anyway

Thanks,
    Uri.

On Mon, Jul 9, 2012 at 2:14 PM, Uri Lublin<uril@xxxxxxxxxx>  wrote:
In preparation for a different SpiceUsbDevice.
---
  gtk/usb-device-manager.c |   15 +++++++++------
  1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index c50a7da..a81db57 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -543,6 +543,7 @@ static void spice_usb_device_manager_add_dev(SpiceUsbDeviceManager  *self,
      libusb_device *device = NULL, **dev_list = NULL;
      const gchar *devtype, *devclass;
      int i, bus, address;
+    gboolean auto_ok = FALSE;

      devtype = g_udev_device_get_property(udev, "DEVTYPE");
      /* Check if this is a usb device (and not an interface) */
@@ -572,6 +573,13 @@ static void spice_usb_device_manager_add_dev(SpiceUsbDeviceManager  *self,
          }
      }

+    if (device&&  priv->auto_connect) {
+        auto_ok = usbredirhost_check_device_filter(
+                            priv->auto_conn_filter_rules,
+                            priv->auto_conn_filter_rules_count,
+                            device, 0) == 0;
+    }
+
      if (!priv->coldplug_list)
          libusb_free_device_list(dev_list, 1);

@@ -584,16 +592,11 @@ static void spice_usb_device_manager_add_dev(SpiceUsbDeviceManager  *self,
      g_ptr_array_add(priv->devices, device);

      if (priv->auto_connect) {
-        gboolean can_redirect, auto_ok;
+        gboolean can_redirect;

          can_redirect = spice_usb_device_manager_can_redirect_device(
                                          self, (SpiceUsbDevice *)device, NULL);

-        auto_ok = usbredirhost_check_device_filter(
-                            priv->auto_conn_filter_rules,
-                            priv->auto_conn_filter_rules_count,
-                            device, 0) == 0;
-
          if (can_redirect&&  auto_ok)
              spice_usb_device_manager_connect_device_async(self,
                                     (SpiceUsbDevice *)device, NULL,
--
1.7.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel



_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]