[Spice-devel] [PATCH v8 06/20] usb-backend: add safe check on attach()

Victor Toso victortoso at redhat.com
Thu Sep 19 14:11:19 UTC 2019


From: Frediano Ziglio <fziglio at redhat.com>

At this moment, spice_usb_backend_channel_attach() is only related to
real devices and this call might happen on channel-up event that can
possibly come before usbredirhost has been created.

Signed-off-by: Victor Toso <victortoso at redhat.com>
---
 src/usb-backend.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/usb-backend.c b/src/usb-backend.c
index 14429cf..c4d8e20 100644
--- a/src/usb-backend.c
+++ b/src/usb-backend.c
@@ -721,6 +721,11 @@ gboolean spice_usb_backend_channel_attach(SpiceUsbBackendChannel *ch,
 
     g_return_val_if_fail(dev != NULL, FALSE);
 
+    // no physical device enabled
+    if (ch->usbredirhost == NULL) {
+        return FALSE;
+    }
+
     libusb_device_handle *handle = NULL;
 
     /*
-- 
2.21.0



More information about the Spice-devel mailing list