[PATCH 2/2] 8250.c: port.lock is irq-safe

Andy Whitcroft apw at canonical.com
Mon Feb 9 13:51:59 UTC 2009


From: Borislav Petkov <petkovbb at googlemail.com>

Bug: #280821
commit c389d27b5e643d745f55ffb939b1426060ba63d4 upstream

serial8250_startup() doesn't disable interrupts while taking the &up->port.lock
which might race against the interrupt handler serial8250_interrupt(), which
when entered, will deadlock waiting for the lock to be released.

Signed-off-by: Borislav Petkov <petkovbb at gmail.com>
Tested-by: Ingo Molnar <mingo at elte.hu>
Cc: Alan Cox <alan at lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
Signed-off-by: Andy Whitcroft <apw at canonical.com>
---
 drivers/serial/8250.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 9b434a6..d82399b 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -1821,7 +1821,7 @@ static int serial8250_startup(struct uart_port *port)
 		 * the interrupt is enabled.  Delays are necessary to
 		 * allow register changes to become visible.
 		 */
-		spin_lock(&up->port.lock);
+		spin_lock_irqsave(&up->port.lock, flags);
 		if (up->port.flags & UPF_SHARE_IRQ)
 			disable_irq_nosync(up->port.irq);
 
@@ -1837,7 +1837,7 @@ static int serial8250_startup(struct uart_port *port)
 
 		if (up->port.flags & UPF_SHARE_IRQ)
 			enable_irq(up->port.irq);
-		spin_unlock(&up->port.lock);
+		spin_unlock_irqrestore(&up->port.lock, flags);
 
 		/*
 		 * If the interrupt is not reasserted, setup a timer to
-- 
1.6.1.2.419.g0d87e





More information about the kernel-team mailing list