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

Christophe Fergeau cfergeau at redhat.com
Tue Nov 15 11:07:45 UTC 2016


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

On Tue, Nov 15, 2016 at 12:26:55AM +0100, Victor Toso wrote:
> From: Victor Toso <me at victortoso.com>
> 
> As spice_usb_device_manager_get() can be NULL
> Signed-off-by: Victor Toso <victortoso at 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 at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20161115/cfbb71d5/attachment.sig>


More information about the Spice-devel mailing list