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

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

 



Hi,

On Wed, Sep 18, 2019 at 06:09:24AM -0400, Frediano Ziglio wrote:
> > 
> > From: Frediano Ziglio <fziglio@xxxxxxxxxx>
> > 
> > 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?

I don't think I did. I recall reading the code to understand the
check from real-device perspective.

> 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).

It is a fact that we shouldn't call this function without
usbredirhost on real-device scenario. I can extend the commit log
if you think it makes sense, adding something like:

" before usbredirhost has been created.".concat(" This checks
also becomes a must in following patches while introducing
emulated devices")

Otherwise, if you prefer that I squash it back, let me know.
 
> > Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>
> > ---
> >  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

Attachment: signature.asc
Description: PGP signature

_______________________________________________
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]