mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
serial: ma35d1: Fix OF node reference leaks in console init
ma35d1serial_console_init_port() stores matching UART device nodes in
ma35d1serial_uart_nodes[] with an extra of_node_get() so that console
setup can later read the "reg" property. However, the stored references
are never released after console setup has finished using them.
Drop the stored node reference after ma35d1serial_console_setup() reads
the "reg" property, and clear the array slot to avoid leaving a stale
pointer behind. Also release the iterator reference before breaking out
of for_each_matching_node(), since the normal iterator advance will not
run in that path.
Fixes: 930cbf92db ("tty: serial: Add Nuvoton ma35d1 serial driver support")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
Link: https://patch.msgid.link/20260630214043.1887351-1-dbgh9129@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
4f643bef09
commit
8dfea56f35
|
|
@ -608,8 +608,14 @@ static int __init ma35d1serial_console_setup(struct console *co, char *options)
|
|||
if (!np || !p)
|
||||
return -ENODEV;
|
||||
|
||||
if (of_property_read_u32_array(np, "reg", val32, ARRAY_SIZE(val32)) != 0)
|
||||
if (of_property_read_u32_array(np, "reg", val32, ARRAY_SIZE(val32)) != 0) {
|
||||
of_node_put(np);
|
||||
ma35d1serial_uart_nodes[co->index] = NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
of_node_put(np);
|
||||
ma35d1serial_uart_nodes[co->index] = NULL;
|
||||
|
||||
p->port.iobase = val32[1];
|
||||
p->port.membase = ioremap(p->port.iobase, MA35_UART_REG_SIZE);
|
||||
|
|
@ -648,8 +654,10 @@ static void ma35d1serial_console_init_port(void)
|
|||
of_node_get(np);
|
||||
ma35d1serial_uart_nodes[i] = np;
|
||||
i++;
|
||||
if (i == MA35_UART_NR)
|
||||
if (i == MA35_UART_NR) {
|
||||
of_node_put(np);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user