From 20ca279fca32cb5ca40629bec3b74d550761dde4 Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Sat, 26 Sep 2026 20:13:42 -0700 Subject: [PATCH] fix(main): ignore a LoaderEntryDefault that matches no entry When LoaderEntryDefault was set, every entry that didn't match it was unmarked as the default, including the one set by default-entry. If the variable named an entry that no longer exists, such as a removed kernel, the configured default was lost and the first entry booted instead. Only apply the variable when some entry matches it. --- crates/boot/src/main.rs | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/crates/boot/src/main.rs b/crates/boot/src/main.rs index d72e1b0..a2332be 100644 --- a/crates/boot/src/main.rs +++ b/crates/boot/src/main.rs @@ -325,15 +325,27 @@ fn run() -> Result<()> { // Apply bootloader interface default entry settings. if let Some(ref bootloader_interface_default_entry) = bootloader_interface_default_entry { - // Iterate over all the entries and mark the default entry as the one specified. - for entry in &mut entries { - // Mark the entry as the default entry if it matches the specified entry. - // If the entry does not match the specified entry, unmark it as the default entry. - if entry.is_match(bootloader_interface_default_entry) { - entry.mark_default(); - } else { - entry.unmark_default(); + if entries + .iter() + .any(|entry| entry.is_match(bootloader_interface_default_entry)) + { + // Iterate over all the entries and mark the default entry as the one specified. + for entry in &mut entries { + // Mark the entry as the default entry if it matches the specified entry. + // If the entry does not match the specified entry, unmark it as the default entry. + if entry.is_match(bootloader_interface_default_entry) { + entry.mark_default(); + } else { + entry.unmark_default(); + } } + } else { + // If no entry matches, such as when the entry was removed, the setting is ignored + // so that the configured default entry is still used. + warn!( + "ignoring bootloader interface default entry '{}': no matching entry", + bootloader_interface_default_entry + ); } }