Patch: fix serial.c race prevention bug
Alan, lkml,
serial.c appears to contain a bug in the race prevention code:
/*
* If we're about to load something into the transmit
* register, we'll pretend the transmitter isn't empty to
* avoid a race condition (depending on when the transmit
* interrupt happens).
*/
if (info->x_char ||
((CIRC_CNT(info->xmit.head, info->xmit.tail,
SERIAL_XMIT_SIZE) > 0) &&
!info->tty->stopped && !info->tty->hw_stopped))
result &= TIOCSER_TEMT;The comment doesn't agree with the action the code is taking, and, since result is either 0 or TIOCSER_TEMT anyway, it is a no-op whether the if condition is true or false.
The following patch makes the race prevention code actually do something, namely what is described in the comment.
This is only an issue for people using the TIOCSERGETLSR ioctl.
drivers/char/serial.c +1 -1
@@ -2250,7 +2250,7 @@ ((CIRC_CNT (info->xmit.head, info->xmit.tail,SERIAL_XMIT_SIZE ) >0 ) && !info->tty->stopped && !info->tty->hw_stopped)) - result &= TIOCSER_TEMT; + result &= ~TIOCSER_TEMT;if (copy_to_user (value, &result,sizeof (int )))return -EFAULT ;
--
Russell King ([email protected]) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html