Skip to content

Commit

Permalink
serial: msm_serial: disable interrupts in __msm_console_write()
Browse files Browse the repository at this point in the history
[ Upstream commit aabdbb1 ]

__msm_console_write() assumes that interrupts are disabled, but
with threaded console printers it is possible that the write()
callback of the console is called with interrupts enabled.

Explicitly disable interrupts using local_irq_save() to preserve
the assumed context.

Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Link: https://lore.kernel.org/r/20220506213324.470461-1-john.ogness@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
jogness authored and gregkh committed Jun 14, 2022
1 parent ff727ab commit 1e3b3a5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/tty/serial/msm_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,7 @@ static inline struct uart_port *msm_get_port_from_line(unsigned int line)
static void __msm_console_write(struct uart_port *port, const char *s,
unsigned int count, bool is_uartdm)
{
unsigned long flags;
int i;
int num_newlines = 0;
bool replaced = false;
Expand All @@ -1610,6 +1611,8 @@ static void __msm_console_write(struct uart_port *port, const char *s,
num_newlines++;
count += num_newlines;

local_irq_save(flags);

if (port->sysrq)
locked = 0;
else if (oops_in_progress)
Expand Down Expand Up @@ -1655,6 +1658,8 @@ static void __msm_console_write(struct uart_port *port, const char *s,

if (locked)
spin_unlock(&port->lock);

local_irq_restore(flags);
}

static void msm_console_write(struct console *co, const char *s,
Expand Down

0 comments on commit 1e3b3a5

Please sign in to comment.