Commit bf2a0be4 authored by Matwey V. Kornilov's avatar Matwey V. Kornilov Committed by Greg Kroah-Hartman

tty: serial: 8250: Cleanup p->em485 in serial8250_unregister_port

Formally, currently there is no memory leak, but if
serial8250_ports[line] is reused with other 8250 driver, then em485
will be already activated and it will cause issues.

Fixes: e490c914 ("tty: Add software emulated RS485 support for 8250")
Signed-off-by: default avatarMatwey V. Kornilov <matwey@sai.msu.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 54555919
...@@ -1074,6 +1074,15 @@ void serial8250_unregister_port(int line) ...@@ -1074,6 +1074,15 @@ void serial8250_unregister_port(int line)
struct uart_8250_port *uart = &serial8250_ports[line]; struct uart_8250_port *uart = &serial8250_ports[line];
mutex_lock(&serial_mutex); mutex_lock(&serial_mutex);
if (uart->em485) {
unsigned long flags;
spin_lock_irqsave(&uart->port.lock, flags);
serial8250_em485_destroy(uart);
spin_unlock_irqrestore(&uart->port.lock, flags);
}
uart_remove_one_port(&serial8250_reg, &uart->port); uart_remove_one_port(&serial8250_reg, &uart->port);
if (serial8250_isa_devs) { if (serial8250_isa_devs) {
uart->port.flags &= ~UPF_BOOT_AUTOCONF; uart->port.flags &= ~UPF_BOOT_AUTOCONF;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment