[Spice-devel,spice-gtk,v1,5/5] channel-usbredir: handle failure from SpiceUsbDeviceManager

Submitted by Victor Toso on Nov. 14, 2016, 11:26 p.m.

Details

Message ID 20161114232655.32459-5-victortoso@redhat.com
State Accepted
Commit d3c29773b1654085ef6653643b1f790985b8454b
Headers show
Series "Series without cover letter" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Victor Toso Nov. 14, 2016, 11:26 p.m.
From: Victor Toso <me@victortoso.com>

As spice_usb_device_manager_get() can be NULL
Signed-off-by: Victor Toso <victortoso@redhat.com>
---
 src/channel-usbredir.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
index add7d5e..4837d68 100644
--- a/src/channel-usbredir.c
+++ b/src/channel-usbredir.c
@@ -293,6 +293,7 @@  static gboolean spice_usbredir_channel_open_device(
     SpiceSession *session;
     libusb_device_handle *handle = NULL;
     int rc, status;
+    SpiceUsbDeviceManager *manager;
 
     g_return_val_if_fail(priv->state == STATE_DISCONNECTED
 #ifdef USE_POLKIT
@@ -317,7 +318,10 @@  static gboolean spice_usbredir_channel_open_device(
     }
 
     session = spice_channel_get_session(SPICE_CHANNEL(channel));
-    priv->usb_device_manager = g_object_ref(spice_usb_device_manager_get(session, NULL));
+    manager = spice_usb_device_manager_get(session, NULL);
+    g_return_val_if_fail(manager != NULL, FALSE);
+
+    priv->usb_device_manager = g_object_ref(manager);
     if (!spice_usb_device_manager_start_event_listening(priv->usb_device_manager, err)) {
         usbredirhost_set_device(priv->host, NULL);
         return FALSE;

Comments

Acked-by: Christophe Fergeau <cfergeau@redhat.com>

On Tue, Nov 15, 2016 at 12:26:55AM +0100, Victor Toso wrote:
> From: Victor Toso <me@victortoso.com>
> 
> As spice_usb_device_manager_get() can be NULL
> Signed-off-by: Victor Toso <victortoso@redhat.com>
> ---
>  src/channel-usbredir.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
> index add7d5e..4837d68 100644
> --- a/src/channel-usbredir.c
> +++ b/src/channel-usbredir.c
> @@ -293,6 +293,7 @@ static gboolean spice_usbredir_channel_open_device(
>      SpiceSession *session;
>      libusb_device_handle *handle = NULL;
>      int rc, status;
> +    SpiceUsbDeviceManager *manager;
>  
>      g_return_val_if_fail(priv->state == STATE_DISCONNECTED
>  #ifdef USE_POLKIT
> @@ -317,7 +318,10 @@ static gboolean spice_usbredir_channel_open_device(
>      }
>  
>      session = spice_channel_get_session(SPICE_CHANNEL(channel));
> -    priv->usb_device_manager = g_object_ref(spice_usb_device_manager_get(session, NULL));
> +    manager = spice_usb_device_manager_get(session, NULL);
> +    g_return_val_if_fail(manager != NULL, FALSE);
> +
> +    priv->usb_device_manager = g_object_ref(manager);
>      if (!spice_usb_device_manager_start_event_listening(priv->usb_device_manager, err)) {
>          usbredirhost_set_device(priv->host, NULL);
>          return FALSE;
> -- 
> 2.9.3
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel