From 72331168beace30cfa5c560cec25298228e2f1ca Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Fri, 6 Aug 2021 14:36:55 +0300 Subject: [PATCH] Kernel: Hold the global logging lock in dbgputch This was not an active issue as sys$dbgputch (the only user of this function) is not actually used anywhere. --- Kernel/kprintf.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Kernel/kprintf.cpp b/Kernel/kprintf.cpp index 4f22b270dcf..253c55b2f3b 100644 --- a/Kernel/kprintf.cpp +++ b/Kernel/kprintf.cpp @@ -143,20 +143,26 @@ int snprintf(char* buffer, size_t size, const char* fmt, ...) return ret; } -extern "C" void dbgputch(char ch) +static inline void internal_dbgputch(char ch) { if (serial_debug) serial_putch(ch); IO::out8(IO::BOCHS_DEBUG_PORT, ch); } +extern "C" void dbgputch(char ch) +{ + ScopedSpinLock lock(s_log_lock); + internal_dbgputch(ch); +} + extern "C" void dbgputstr(const char* characters, size_t length) { if (!characters) return; ScopedSpinLock lock(s_log_lock); for (size_t i = 0; i < length; ++i) - dbgputch(characters[i]); + internal_dbgputch(characters[i]); } extern "C" void kernelputstr(const char* characters, size_t length)