From 0bd8c74cc0b7aa10e1cd74b54afabe6528ed5a46 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Tue, 10 Apr 2018 11:09:37 -0500 Subject: [PATCH] thunderbolt-power: If a timer is still running from coldplug, stop it (#457) A race condition is hypothesized in the following scenario: 1. User starts up the system and fwupd doesn't start automatically. 2. User manually calls fwupdmgr install blah.cab (or fwupdmgr update really) which uses dbus activation to start fwupd systemd unit. 3. This runs coldplug on thunderbolt plugin, no devices found. Thunderbolt power runs coldplug routine. a. This sets forcepower with a timeout to turn off after 20 seconds. b. Coldplug exits. 4. update routine starts a. Thunderbolt plugin starts flash routine. b. Thunderbolt power plugin turns off force power in middle of flash routine. c. Issue described happens. --- plugins/thunderbolt-power/fu-plugin-thunderbolt-power.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/thunderbolt-power/fu-plugin-thunderbolt-power.c b/plugins/thunderbolt-power/fu-plugin-thunderbolt-power.c index 0d7967472..e74846a0b 100644 --- a/plugins/thunderbolt-power/fu-plugin-thunderbolt-power.c +++ b/plugins/thunderbolt-power/fu-plugin-thunderbolt-power.c @@ -229,6 +229,12 @@ fu_plugin_update_prepare (FuPlugin *plugin, if (g_strcmp0 (fu_device_get_plugin (device), "thunderbolt") != 0) return TRUE; + /* reset any timers that might still be running from coldplug */ + if (data->timeout_id != 0) { + g_source_remove (data->timeout_id); + data->timeout_id = 0; + } + devpath = fu_device_get_metadata (device, "sysfs-path"); udevice = g_udev_client_query_by_sysfs_path (data->udev, devpath);