From 262ccbcf302f8dae0baccd1747406b18be7cd60e Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sat, 14 Jan 2017 12:11:30 -0500 Subject: serial: Be careful with comparison of transmit_max to transmit_pos There is a small possibility that a shutdown could occur between clearing transmit_max and clearing transmit_pos - so make sure to handle the case where transmit_pos > transmit_max. Signed-off-by: Kevin O'Connor --- src/avr/serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/avr/serial.c') diff --git a/src/avr/serial.c b/src/avr/serial.c index 8c0da553..0b5fea1f 100644 --- a/src/avr/serial.c +++ b/src/avr/serial.c @@ -115,7 +115,7 @@ char * console_get_output(uint8_t len) { uint8_t tpos = readb(&transmit_pos), tmax = readb(&transmit_max); - if (tpos == tmax) { + if (tpos >= tmax) { tpos = tmax = 0; writeb(&transmit_max, 0); writeb(&transmit_pos, 0); -- cgit v1.2.3-70-g09d2