diff options
author | Randy Witt <rewitt@declaratino.com> | 2013-10-17 16:56:47 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-12-08 19:44:21 -0500 |
commit | 42b6a1baa3ec18de2eb15baa250da6203eeb2d39 (patch) | |
tree | 02c53dbbe7be345a2335e0b54c6cc05d01b0ff9e | |
parent | dc1ccc48159d63eca5089e507c82c7d22ef60839 (diff) |
serial_core: Don't re-initialize a previously initialized spinlock.
The uart_set_options() code unconditionally initalizes the spinlock
on the port. This can cause a deadlock in some situations.
One instance that exposed the problem, was when writing to
/sys/module/kgdboc/parameters/kgdboc to use ttyS0 when the console
is already running on ttyS0. If the spinlock is re-initialized
while the lock is held due to output to the console, there
is a deadlock.
Assume the spinlock is initialized if the port is a console.
Signed-off-by: Randy Witt <rewitt@declaratino.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/tty/serial/serial_core.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 0f02351c9239..ece2049bd270 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c | |||
@@ -1830,9 +1830,13 @@ uart_set_options(struct uart_port *port, struct console *co, | |||
1830 | /* | 1830 | /* |
1831 | * Ensure that the serial console lock is initialised | 1831 | * Ensure that the serial console lock is initialised |
1832 | * early. | 1832 | * early. |
1833 | * If this port is a console, then the spinlock is already | ||
1834 | * initialised. | ||
1833 | */ | 1835 | */ |
1834 | spin_lock_init(&port->lock); | 1836 | if (!(uart_console(port) && (port->cons->flags & CON_ENABLED))) { |
1835 | lockdep_set_class(&port->lock, &port_lock_key); | 1837 | spin_lock_init(&port->lock); |
1838 | lockdep_set_class(&port->lock, &port_lock_key); | ||
1839 | } | ||
1836 | 1840 | ||
1837 | memset(&termios, 0, sizeof(struct ktermios)); | 1841 | memset(&termios, 0, sizeof(struct ktermios)); |
1838 | 1842 | ||