From be551d420e6c839d5059290f563fb5b1fe46c6bb Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 30 Jul 2025 13:40:36 +0100 Subject: [PATCH] [serial] Explicitly initialise serial console UART to NULL When debugging is enabled for the device tree or memory map parsing code, the active serial console UART variable will be accessed during early initialisation, before the .bss section has been zeroed. Place this variable in the .data section (by providing an explicit initialiser), so that reading this variable is well defined even during early initialisation. Signed-off-by: Michael Brown --- src/core/serial.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/serial.c b/src/core/serial.c index 0883ad051..f3b33cd90 100644 --- a/src/core/serial.c +++ b/src/core/serial.c @@ -61,8 +61,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define COMSPEED 0 #endif -/** Active serial console UART */ -struct uart *serial_console; +/** Active serial console UART + * + * Explicitly initialised to @c NULL since this variable may be + * accessed before .bss has been zeroed. + */ +struct uart *serial_console = NULL; /** * Get fixed serial console UART -- 2.47.2