Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Rich Felker and committed by
Greg Kroah-Hartman
9e370d2c 7cdcc29e

+4
+4
drivers/tty/serial/uartlite.c
··· 194 194 { 195 195 struct uart_port *port = dev_id; 196 196 int busy, n = 0; 197 + unsigned long flags; 197 198 199 + spin_lock_irqsave(&port->lock, flags); 198 200 do { 199 201 int stat = uart_in32(ULITE_STATUS, port); 200 202 busy = ulite_receive(port, stat); 201 203 busy |= ulite_transmit(port, stat); 202 204 n++; 203 205 } while (busy); 206 + 207 + spin_unlock_irqrestore(&port->lock, flags); 204 208 205 209 /* work done? */ 206 210 if (n > 1) {