kernel: printk: fix log buffer overflow

This commit is contained in:
2026-03-14 22:15:39 +00:00
parent c628390f4a
commit 5e7a467dff
2 changed files with 34 additions and 14 deletions

View File

@@ -1,9 +1,9 @@
#include <kernel/console.h>
#include <kernel/queue.h>
#include <kernel/locks.h>
#include <kernel/libc/string.h>
#include <kernel/locks.h>
#include <kernel/queue.h>
static struct queue consoles;
static struct queue consoles = {0};
static spin_lock_t consoles_lock = SPIN_LOCK_INIT;
static void unregister_boot_consoles(void)
@@ -11,7 +11,8 @@ static void unregister_boot_consoles(void)
struct queue_entry *cur = queue_first(&consoles);
while (cur) {
struct queue_entry *next = cur->qe_next;
struct console *con = QUEUE_CONTAINER(struct console, c_list, cur);
struct console *con
= QUEUE_CONTAINER(struct console, c_list, cur);
if (con->c_flags & CON_BOOT) {
queue_delete(&consoles, cur);
}
@@ -25,7 +26,8 @@ kern_status_t console_register(struct console *con)
unsigned long flags;
spin_lock_irqsave(&consoles_lock, &flags);
queue_foreach (struct console, cur, &consoles, c_list) {
queue_foreach(struct console, cur, &consoles, c_list)
{
if (!strcmp(cur->c_name, con->c_name)) {
spin_unlock_irqrestore(&consoles_lock, flags);
return KERN_NAME_EXISTS;