[PATCH 1/1] serial: core: Initialise spin lock before use in uart_configure_port()
From: Andy Shevchenko
Date: Sat Jul 04 2020 - 12:30:39 EST
In case of the port to be used as a console we must initialise
a spin lock before use.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
drivers/tty/serial/serial_core.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 3cc183acf7ba..a81b4900eb60 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2371,6 +2371,13 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state,
/* Power up port for set_mctrl() */
uart_change_pm(state, UART_PM_STATE_ON);
+ /*
+ * If this driver supports console, and it hasn't been
+ * successfully registered yet, initialise spin lock for it.
+ */
+ if (port->cons && !(port->cons->flags & CON_ENABLED))
+ spin_lock_init(&port->lock);
+
/*
* Ensure that the modem control lines are de-activated.
* keep the DTR setting that is set in uart_set_options()
--
2.27.0
> Or did you mean to test it in complement of my patch?
No, the idea to avoid "fixing" driver as you rightfully noticed a double init issue.
--
With Best Regards,
Andy Shevchenko