diff --git a/Kernel/Graphics/GraphicsManagement.cpp b/Kernel/Graphics/GraphicsManagement.cpp index 4411ec45639..ef1f9ac1957 100644 --- a/Kernel/Graphics/GraphicsManagement.cpp +++ b/Kernel/Graphics/GraphicsManagement.cpp @@ -189,15 +189,20 @@ UNMAP_AFTER_INIT bool GraphicsManagement::initialize() * a variant that is suitable for ISA VGA handling, and not PCI adapters. */ + ScopeGuard assign_console_on_initialization_exit([this] { + if (!m_console) { + // If no graphics driver was instantiated and we had a bootloader provided + // framebuffer console we can simply re-use it. + if (auto* boot_console = g_boot_console.load()) { + m_console = *boot_console; + boot_console->unref(); // Drop the leaked reference from Kernel::init() + } + } + }); + auto graphics_subsystem_mode = kernel_command_line().graphics_subsystem_mode(); if (graphics_subsystem_mode == CommandLine::GraphicsSubsystemMode::Disabled) { VERIFY(!m_console); - // If no graphics driver was instantiated and we had a bootloader provided - // framebuffer console we can simply re-use it. - if (auto* boot_console = g_boot_console.load()) { - m_console = *boot_console; - boot_console->unref(); // Drop the leaked reference from Kernel::init() - } return true; } @@ -232,15 +237,6 @@ UNMAP_AFTER_INIT bool GraphicsManagement::initialize() return true; } - if (!m_console) { - // If no graphics driver was instantiated and we had a bootloader provided - // framebuffer console we can simply re-use it. - if (auto* boot_console = g_boot_console.load()) { - m_console = *boot_console; - boot_console->unref(); // Drop the leaked reference from Kernel::init() - } - } - if (m_graphics_devices.is_empty()) { dbgln("No graphics adapter was initialized."); return false;