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

Frediano Ziglio fziglio at redhat.com
Wed Sep 18 10:09:24 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.


Were you able to reproduce this condition?

If I put the check I put because the code will support not having
usbredirhost at all, not because it will be created in the future
(in this case will ever be NULL).

> 
> 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 6ed957c..68faaae 100644
> --- a/src/usb-backend.c
> +++ b/src/usb-backend.c
> @@ -720,6 +720,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;
>  
>      /*

Frediano


More information about the Spice-devel mailing list