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 <kevin@koconnor.net>
This commit is contained in:
parent
7567885115
commit
262ccbcf30
|
@ -115,7 +115,7 @@ char *
|
||||||
console_get_output(uint8_t len)
|
console_get_output(uint8_t len)
|
||||||
{
|
{
|
||||||
uint8_t tpos = readb(&transmit_pos), tmax = readb(&transmit_max);
|
uint8_t tpos = readb(&transmit_pos), tmax = readb(&transmit_max);
|
||||||
if (tpos == tmax) {
|
if (tpos >= tmax) {
|
||||||
tpos = tmax = 0;
|
tpos = tmax = 0;
|
||||||
writeb(&transmit_max, 0);
|
writeb(&transmit_max, 0);
|
||||||
writeb(&transmit_pos, 0);
|
writeb(&transmit_pos, 0);
|
||||||
|
|
|
@ -120,7 +120,7 @@ char *
|
||||||
console_get_output(uint8_t len)
|
console_get_output(uint8_t len)
|
||||||
{
|
{
|
||||||
uint32_t tpos = readb(&transmit_pos), tmax = readb(&transmit_max);
|
uint32_t tpos = readb(&transmit_pos), tmax = readb(&transmit_max);
|
||||||
if (tpos == tmax) {
|
if (tpos >= tmax) {
|
||||||
tpos = tmax = 0;
|
tpos = tmax = 0;
|
||||||
writeb(&transmit_max, 0);
|
writeb(&transmit_max, 0);
|
||||||
writeb(&transmit_pos, 0);
|
writeb(&transmit_pos, 0);
|
||||||
|
|
Loading…
Reference in New Issue