]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[serial] Explicitly initialise serial console UART to NULL
authorMichael Brown <mcb30@ipxe.org>
Wed, 30 Jul 2025 12:40:36 +0000 (13:40 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 30 Jul 2025 12:40:36 +0000 (13:40 +0100)
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 <mcb30@ipxe.org>
src/core/serial.c

index 0883ad051b0c43c59df8ea0c292ab2fbb45e874c..f3b33cd90ea2c278efdf1238f8784ff36031b4b3 100644 (file)
@@ -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