tty/serial: atmel: fix race condition (TX+DMA)

commit 31ca2c63fdc0aee725cbd4f207c1256f5deaabde upstream.

If uart_flush_buffer() is called between atmel_tx_dma() and
atmel_complete_tx_dma(), the circular buffer has been cleared, but not
That leads to a circular buffer overflow (dumping (UART_XMIT_SIZE -
atmel_port->tx_len) bytes).

Tested-by: Nicolas Ferre <>
[rg] backport to 3.12
Signed-off-by: Richard Genoud <>
Signed-off-by: Greg Kroah-Hartman <>
Signed-off-by: Jiri Slaby <>
1 file changed