Skip to content

Commit d631eeb

Browse files
authored
yet another uart race condition fix (sonic-net#75)
Signed-off-by: Guohan Lu <[email protected]>
1 parent 39d0301 commit d631eeb

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

patch/driver-uart-fix-another-race-between-uart_put_char-and-uart_shutdow.patch

+18-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ From: Guohan Lu <[email protected]>
44

55
this is complete the fix in a5ba1d95e46ecaea638ddd7cd144107c783acb5d
66
---
7-
drivers/tty/serial/serial_core.c | 6 ++++--
8-
1 file changed, 4 insertions(+), 2 deletions(-)
7+
drivers/tty/serial/serial_core.c | 12 ++++++++----
8+
1 file changed, 8 insertions(+), 4 deletions(-)
99

1010
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
11-
index 53e6db8..ec1187d 100644
11+
index 53e6db8..c98a5d0 100644
1212
--- a/drivers/tty/serial/serial_core.c
1313
+++ b/drivers/tty/serial/serial_core.c
1414
@@ -530,10 +530,12 @@ static int uart_put_char(struct tty_struct *tty, unsigned char c)
@@ -26,3 +26,18 @@ index 53e6db8..ec1187d 100644
2626
if (port && uart_circ_chars_free(circ) != 0) {
2727
circ->buf[circ->head] = c;
2828
circ->head = (circ->head + 1) & (UART_XMIT_SIZE - 1);
29+
@@ -567,10 +569,12 @@ static int uart_write(struct tty_struct *tty,
30+
}
31+
32+
circ = &state->xmit;
33+
- if (!circ->buf)
34+
+ port = uart_port_lock(state, flags);
35+
+ if (!circ->buf) {
36+
+ uart_port_unlock(port, flags);
37+
return 0;
38+
+ }
39+
40+
- port = uart_port_lock(state, flags);
41+
while (port) {
42+
c = CIRC_SPACE_TO_END(circ->head, circ->tail, UART_XMIT_SIZE);
43+
if (count < c)

0 commit comments

Comments
 (0)