From b4fb6fa6aa0e8b9548cde95e25f0c2724f1a64d5 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 9 Feb 2022 13:49:31 +0000 Subject: [PATCH] flashrom: Fix loading devices in coreboot mode We were specifying _REQUIRE_HWID but the plugin list was not yet loaded when we were trying all the HwIds. --- src/fu-engine.c | 14 +++++++------- src/fu-plugin-list.c | 6 ++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/fu-engine.c b/src/fu-engine.c index 97fc8aaea..6e93511b8 100644 --- a/src/fu-engine.c +++ b/src/fu-engine.c @@ -7144,13 +7144,6 @@ fu_engine_load(FuEngine *self, FuEngineLoadFlags flags, GError **error) if (flags & FU_ENGINE_LOAD_FLAG_HWINFO) fu_context_load_hwinfo(self->ctx, NULL); - /* set quirks for each hwid */ - guids = fu_context_get_hwid_guids(self->ctx); - for (guint i = 0; i < guids->len; i++) { - const gchar *hwid = g_ptr_array_index(guids, i); - fu_engine_load_quirks_for_hwid(self, hwid); - } - /* load AppStream metadata */ if (!fu_engine_load_metadata_store(self, flags, error)) { g_prefix_error(error, "Failed to load AppStream data: "); @@ -7219,6 +7212,13 @@ fu_engine_load(FuEngine *self, FuEngineLoadFlags flags, GError **error) return FALSE; } + /* set quirks for each hwid */ + guids = fu_context_get_hwid_guids(self->ctx); + for (guint i = 0; i < guids->len; i++) { + const gchar *hwid = g_ptr_array_index(guids, i); + fu_engine_load_quirks_for_hwid(self, hwid); + } + /* set up battery threshold */ fu_engine_context_set_battery_threshold(self->ctx); diff --git a/src/fu-plugin-list.c b/src/fu-plugin-list.c index fd7ba5694..83a388420 100644 --- a/src/fu-plugin-list.c +++ b/src/fu-plugin-list.c @@ -121,6 +121,12 @@ fu_plugin_list_find_by_name(FuPluginList *self, const gchar *name, GError **erro g_return_val_if_fail(name != NULL, NULL); g_return_val_if_fail(error == NULL || *error == NULL, NULL); + /* sanity check */ + if (self->plugins->len == 0) { + g_set_error_literal(error, FWUPD_ERROR, FWUPD_ERROR_NOT_FOUND, "no plugins loaded"); + return NULL; + } + plugin = g_hash_table_lookup(self->plugins_hash, name); if (plugin == NULL) { g_set_error(error, FWUPD_ERROR, FWUPD_ERROR_NOT_FOUND, "no plugin %s found", name);