Skip to content

Commit

Permalink
8250: fix possible deadlock between serial8250_handle_port() and seri…
Browse files Browse the repository at this point in the history
…al8250_interrupt()

Commit 40b36da introduced possibility that serial8250_backup_timeout() ->
serial8250_handle_port() locks port.lock without disabling irqs, thus
allowing deadlock against interrupt handler (port.lock is acquired in
serial8250_interrupt()).

Spotted by lockdep.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Cc: Dave Jones <davej@codemonkey.org.uk>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Jiri Kosina authored and Linus Torvalds committed Apr 24, 2007
1 parent c5408b8 commit 4bf3631
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/serial/8250.c
Original file line number Diff line number Diff line change
Expand Up @@ -1334,8 +1334,9 @@ static inline void
serial8250_handle_port(struct uart_8250_port *up)
{
unsigned int status;
unsigned long flags;

spin_lock(&up->port.lock);
spin_lock_irqsave(&up->port.lock, flags);

status = serial_inp(up, UART_LSR);

Expand All @@ -1347,7 +1348,7 @@ serial8250_handle_port(struct uart_8250_port *up)
if (status & UART_LSR_THRE)
transmit_chars(up);

spin_unlock(&up->port.lock);
spin_unlock_irqrestore(&up->port.lock, flags);
}

/*
Expand Down

0 comments on commit 4bf3631

Please sign in to comment.