From 5eab21e98ac19be7ac9e1969ef992ca10764841e Mon Sep 17 00:00:00 2001 From: antifallobst Date: Sun, 12 Feb 2023 09:51:32 +0100 Subject: [PATCH] fix (kernel): Added cpu_state NULL check in panic screen --- kernel/src/utils/panic.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/src/utils/panic.c b/kernel/src/utils/panic.c index cf18a4f..7f2ab69 100644 --- a/kernel/src/utils/panic.c +++ b/kernel/src/utils/panic.c @@ -57,9 +57,15 @@ void panic_log_registers(cpu_state_T* state) { void panic(cpu_state_T* state, string_t message) { log(LOG_ERROR, "!=====[ KERNEL PANIC ]=====!"); + log(LOG_NONE, "Error Message: %s", message); + + if (state == NULL) { + log(LOG_WARNING, "No detailed Information available (cpu_state null reference)"); + CORE_HALT_FOREVER + } + log(LOG_NONE, "Interrupt ID: 0x%xb", state->interrupt_id); - log(LOG_NONE, "Error Code: 0b%.32b", state->error_code); - log(LOG_NONE, "Error Message: %s\n", message); + log(LOG_NONE, "Error Code: 0b%.32b\n", state->error_code); panic_log_paging_info(state);