Skip to contentSkip to conversation

term/ns8250: return in case of a null SPCR base addresses

PATCH In review Leo Sandoval 1 participant 2 messages Jan 9, 2025 – Jan 22, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 term/ns8250: return in case of a null SPCR base addresses

Serial SPCR MMIO null address are invalid, so return from function, otherwise invalid 'mmio,0' port names are generated halting the system when running terminal_input|output commands.

---
 grub-core/term/ns8250.c | 3 +++
 1 file changed, 3 insertions(+)
grub-core/term/ns8250.c +3 -0
index 23e8e0904..4ac0bc06a 100644
@@ -407,6 +407,9 @@ grub_serial_ns8250_add_mmio (grub_addr_t addr, unsigned int acc_size,
   struct grub_serial_port *p;
   unsigned i;
 
+  if (addr == NULL)
+    return NULL;
+
   for (i = 0; i < GRUB_SERIAL_PORT_NUM; i++)
     if (com_ports[i].use_mmio == true && com_ports[i].mmio.base == addr)
       {
Signature · 7 lines
2.47.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#1 lore raw

Please ignore this patch, a better approach is
https://lists.gnu.org/archive/html/grub-devel/2025-01/msg00093.html

Quoted 25 lines · Leo Sandoval

Serial SPCR MMIO null address are invalid, so return from function, otherwise
invalid 'mmio,0' port names are generated halting the system when running terminal_input|output commands.

---
 grub-core/term/ns8250.c | 3 +++
 1 file changed, 3 insertions(+)
grub-core/term/ns8250.c +3 -0
index 23e8e0904..4ac0bc06a 100644
@@ -407,6 +407,9 @@ grub_serial_ns8250_add_mmio (grub_addr_t addr,
 unsigned int acc_size,
   struct grub_serial_port *p;
   unsigned i;
 
+  if (addr == NULL)
+    return NULL;
+
   for (i = 0; i < GRUB_SERIAL_PORT_NUM; i++)
     if (com_ports[i].use_mmio == true && com_ports[i].mmio.base == addr)
       {
Quoted 9 lines

--
2.47.0

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel