From d631eeb37fea2d6fc63e57eec8a8084109b678aa Mon Sep 17 00:00:00 2001 From: lguohan Date: Sat, 15 Dec 2018 16:51:00 -0800 Subject: [PATCH] yet another uart race condition fix (#75) Signed-off-by: Guohan Lu --- ...tween-uart_put_char-and-uart_shutdow.patch | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/patch/driver-uart-fix-another-race-between-uart_put_char-and-uart_shutdow.patch b/patch/driver-uart-fix-another-race-between-uart_put_char-and-uart_shutdow.patch index 204101805e2c..0e7d5da81866 100644 --- a/patch/driver-uart-fix-another-race-between-uart_put_char-and-uart_shutdow.patch +++ b/patch/driver-uart-fix-another-race-between-uart_put_char-and-uart_shutdow.patch @@ -4,11 +4,11 @@ From: Guohan Lu this is complete the fix in a5ba1d95e46ecaea638ddd7cd144107c783acb5d --- - drivers/tty/serial/serial_core.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) + drivers/tty/serial/serial_core.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c -index 53e6db8..ec1187d 100644 +index 53e6db8..c98a5d0 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -530,10 +530,12 @@ static int uart_put_char(struct tty_struct *tty, unsigned char c) @@ -26,3 +26,18 @@ index 53e6db8..ec1187d 100644 if (port && uart_circ_chars_free(circ) != 0) { circ->buf[circ->head] = c; circ->head = (circ->head + 1) & (UART_XMIT_SIZE - 1); +@@ -567,10 +569,12 @@ static int uart_write(struct tty_struct *tty, + } + + circ = &state->xmit; +- if (!circ->buf) ++ port = uart_port_lock(state, flags); ++ if (!circ->buf) { ++ uart_port_unlock(port, flags); + return 0; ++ } + +- port = uart_port_lock(state, flags); + while (port) { + c = CIRC_SPACE_TO_END(circ->head, circ->tail, UART_XMIT_SIZE); + if (count < c)