[Spice-devel] [PATCH v7 06/20] usb-backend: add safe check on attach()
Victor Toso
victortoso at redhat.com
Thu Sep 19 08:25:55 UTC 2019
Hi,
On Wed, Sep 18, 2019 at 06:09:24AM -0400, Frediano Ziglio wrote:
> >
> > 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?
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 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20190919/55b385f6/attachment.sig>
More information about the Spice-devel
mailing list