소스 검색

Kernel: Ensure that CommandLine is initialized before choosing PanicMode

If the kernel commandline is not initialized, just halt everything.
Liav A 3 년 전
부모
커밋
d67c70d043
3개의 변경된 파일8개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      Kernel/CommandLine.cpp
  2. 1 0
      Kernel/CommandLine.h
  3. 2 0
      Kernel/Panic.cpp

+ 5 - 0
Kernel/CommandLine.cpp

@@ -27,6 +27,11 @@ UNMAP_AFTER_INIT void CommandLine::early_initialize(const char* cmd_line)
     s_cmd_line[length] = '\0';
     s_cmd_line[length] = '\0';
 }
 }
 
 
+bool CommandLine::was_initialized()
+{
+    return s_the != nullptr;
+}
+
 const CommandLine& kernel_command_line()
 const CommandLine& kernel_command_line()
 {
 {
     VERIFY(s_the);
     VERIFY(s_the);

+ 1 - 0
Kernel/CommandLine.h

@@ -45,6 +45,7 @@ class CommandLine {
 public:
 public:
     static void early_initialize(const char* cmd_line);
     static void early_initialize(const char* cmd_line);
     static void initialize();
     static void initialize();
+    static bool was_initialized();
 
 
     enum class Validate {
     enum class Validate {
         Yes,
         Yes,

+ 2 - 0
Kernel/Panic.cpp

@@ -33,6 +33,8 @@ void __panic(const char* file, unsigned int line, const char* function)
 
 
     critical_dmesgln("at {}:{} in {}", file, line, function);
     critical_dmesgln("at {}:{} in {}", file, line, function);
     dump_backtrace(PrintToScreen::Yes);
     dump_backtrace(PrintToScreen::Yes);
+    if (!CommandLine::was_initialized())
+        Processor::halt();
     switch (kernel_command_line().panic_mode()) {
     switch (kernel_command_line().panic_mode()) {
     case PanicMode::Shutdown:
     case PanicMode::Shutdown:
         __shutdown();
         __shutdown();