trivial: Do not allow changing the logical or physical IDs after calling ->setup()

If we allowed this then the DeviceID would change, and chaos ensues.
This commit is contained in:
Richard Hughes 2021-04-22 14:06:25 +01:00
parent 6b64bc7afa
commit f9e9e087d4

View File

@ -2203,6 +2203,16 @@ fu_device_set_logical_id (FuDevice *self, const gchar *logical_id)
if (g_strcmp0 (priv->logical_id, logical_id) == 0)
return;
/* not allowed after ->probe() and ->setup() have completed */
if (priv->done_setup) {
g_warning ("cannot change %s logical ID from %s to %s as "
"FuDevice->setup() has already completed",
fu_device_get_id (self),
priv->logical_id,
logical_id);
return;
}
g_free (priv->logical_id);
priv->logical_id = g_strdup (logical_id);
priv->device_id_valid = FALSE;
@ -2327,6 +2337,16 @@ fu_device_set_physical_id (FuDevice *self, const gchar *physical_id)
if (g_strcmp0 (priv->physical_id, physical_id) == 0)
return;
/* not allowed after ->probe() and ->setup() have completed */
if (priv->done_setup) {
g_warning ("cannot change %s physical ID from %s to %s as "
"FuDevice->setup() has already completed",
fu_device_get_id (self),
priv->physical_id,
physical_id);
return;
}
g_free (priv->physical_id);
priv->physical_id = g_strdup (physical_id);
priv->device_id_valid = FALSE;