logitech-hidpp: Only shutdown the IO channel if it was created

This commit is contained in:
Richard Hughes 2021-05-18 10:12:53 +01:00
parent 6174425ee1
commit 35d37f8d2c
2 changed files with 10 additions and 6 deletions

View File

@ -180,9 +180,11 @@ static gboolean
fu_logitech_hidpp_peripheral_close (FuDevice *device, GError **error) fu_logitech_hidpp_peripheral_close (FuDevice *device, GError **error)
{ {
FuLogitechHidPpPeripheral *self = FU_UNIFYING_PERIPHERAL (device); FuLogitechHidPpPeripheral *self = FU_UNIFYING_PERIPHERAL (device);
if (!fu_io_channel_shutdown (self->io_channel, error)) if (self->io_channel != NULL) {
return FALSE; if (!fu_io_channel_shutdown (self->io_channel, error))
g_clear_object (&self->io_channel); return FALSE;
g_clear_object (&self->io_channel);
}
return TRUE; return TRUE;
} }

View File

@ -49,9 +49,11 @@ static gboolean
fu_logitech_hidpp_runtime_close (FuDevice *device, GError **error) fu_logitech_hidpp_runtime_close (FuDevice *device, GError **error)
{ {
FuLogitechHidPpRuntime *self = FU_UNIFYING_RUNTIME (device); FuLogitechHidPpRuntime *self = FU_UNIFYING_RUNTIME (device);
if (!fu_io_channel_shutdown (self->io_channel, error)) if (self->io_channel != NULL) {
return FALSE; if (!fu_io_channel_shutdown (self->io_channel, error))
g_clear_object (&self->io_channel); return FALSE;
g_clear_object (&self->io_channel);
}
return TRUE; return TRUE;
} }