aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRich Felker <dalias@libc.org>2016-01-08 15:33:50 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-02-07 01:56:43 -0500
commit9e370d2c9f59a63dda0ced3ecd1b55498d97c449 (patch)
tree12c0f8218b6e7f8c29648cc9ab2552be3e23a7bb
parent7cdcc29e4919dc31f494eaf05e46005c28efe832 (diff)
serial-uartlite: fix missing locking in isr
The uartlite driver suffers from missing/duplicate/corrupted character data when the interrupt handler runs concurrently with access to the device from another cpu. Take the port spinlock to exclude concurrent access. Signed-off-by: Rich Felker <dalias@libc.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/uartlite.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index c249aee887d2..ee2e8efdea4a 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -194,7 +194,9 @@ static irqreturn_t ulite_isr(int irq, void *dev_id)
194{ 194{
195 struct uart_port *port = dev_id; 195 struct uart_port *port = dev_id;
196 int busy, n = 0; 196 int busy, n = 0;
197 unsigned long flags;
197 198
199 spin_lock_irqsave(&port->lock, flags);
198 do { 200 do {
199 int stat = uart_in32(ULITE_STATUS, port); 201 int stat = uart_in32(ULITE_STATUS, port);
200 busy = ulite_receive(port, stat); 202 busy = ulite_receive(port, stat);
@@ -202,6 +204,8 @@ static irqreturn_t ulite_isr(int irq, void *dev_id)
202 n++; 204 n++;
203 } while (busy); 205 } while (busy);
204 206
207 spin_unlock_irqrestore(&port->lock, flags);
208
205 /* work done? */ 209 /* work done? */
206 if (n > 1) { 210 if (n > 1) {
207 tty_flip_buffer_push(&port->state->port); 211 tty_flip_buffer_push(&port->state->port);