[PATCH spice-gtk 2/2] usb-device-manager: Fix reference counting getting devices

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

 



spice_usb_device_manager_device_to_bdev increments usb device
counter. The function is just used to check for filter but
than the counter is not decremented causing the object to be
leaked later (or invalid reference counter anyway).
Decrement the counter in any case.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 src/usb-device-manager.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index a035683d..0a04b119 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -1012,8 +1012,12 @@ GPtrArray* spice_usb_device_manager_get_devices_with_filter(
         if (rules) {
             SpiceUsbBackendDevice *bdev =
                 spice_usb_device_manager_device_to_bdev(self, device);
-            if (spice_usb_backend_device_check_filter(bdev, rules, count) != 0)
+            gboolean filter_ok =
+                (spice_usb_backend_device_check_filter(bdev, rules, count) == 0);
+            spice_usb_backend_device_unref(bdev);
+            if (!filter_ok) {
                 continue;
+            }
         }
         g_ptr_array_add(devices_copy, spice_usb_device_ref(device));
     }
-- 
2.20.1

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




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