From f0a08324d0f923527ba611887a3780c1f2cb1578 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Tue, 21 Jan 2025 11:01:26 -0600 Subject: [PATCH] term/ns8250-spcr: Return if redirection is disabled The Microsoft spec for SPCR says "The base address of the Serial Port register set described using the ACPI Generic Address Structure, or 0 if console redirection is disabled". So, return early if redirection is disabled (base address = 0). If this check is not done we may get invalid ports on machines with redirection disabled and boot may hang when reading the grub.cfg file. Signed-off-by: Benjamin Herrenschmidt Reviewed-by: Leo Sandoval Reviewed-by: Daniel Kiper --- grub-core/term/ns8250-spcr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/grub-core/term/ns8250-spcr.c b/grub-core/term/ns8250-spcr.c index 4efaaf768..428b2d59a 100644 --- a/grub-core/term/ns8250-spcr.c +++ b/grub-core/term/ns8250-spcr.c @@ -76,6 +76,11 @@ grub_ns8250_spcr_init (void) config.speed = 115200; break; }; + + /* If base address is 0 it means redirection is disabled. */ + if (spcr->base_addr.addr == 0) + return NULL; + switch (spcr->base_addr.space_id) { case GRUB_ACPI_GENADDR_MEM_SPACE: -- 2.47.2