From 35d37f8d2ca49856b51c03ea14477fc77318349a Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 18 May 2021 10:12:53 +0100 Subject: [PATCH] logitech-hidpp: Only shutdown the IO channel if it was created --- plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.c | 8 +++++--- plugins/logitech-hidpp/fu-logitech-hidpp-runtime.c | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.c b/plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.c index 3aa1ab197..9f7381fec 100644 --- a/plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.c +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.c @@ -180,9 +180,11 @@ static gboolean fu_logitech_hidpp_peripheral_close (FuDevice *device, GError **error) { FuLogitechHidPpPeripheral *self = FU_UNIFYING_PERIPHERAL (device); - if (!fu_io_channel_shutdown (self->io_channel, error)) - return FALSE; - g_clear_object (&self->io_channel); + if (self->io_channel != NULL) { + if (!fu_io_channel_shutdown (self->io_channel, error)) + return FALSE; + g_clear_object (&self->io_channel); + } return TRUE; } diff --git a/plugins/logitech-hidpp/fu-logitech-hidpp-runtime.c b/plugins/logitech-hidpp/fu-logitech-hidpp-runtime.c index 851704d56..05da2aa78 100644 --- a/plugins/logitech-hidpp/fu-logitech-hidpp-runtime.c +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-runtime.c @@ -49,9 +49,11 @@ static gboolean fu_logitech_hidpp_runtime_close (FuDevice *device, GError **error) { FuLogitechHidPpRuntime *self = FU_UNIFYING_RUNTIME (device); - if (!fu_io_channel_shutdown (self->io_channel, error)) - return FALSE; - g_clear_object (&self->io_channel); + if (self->io_channel != NULL) { + if (!fu_io_channel_shutdown (self->io_channel, error)) + return FALSE; + g_clear_object (&self->io_channel); + } return TRUE; }