lkml.org 
[lkml]   [2001]   [Nov]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectPatch: 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.

--- orig/drivers/char/serial.c Sun Oct 28 20:36:48 2001
+++ linux/drivers/char/serial.c Thu Nov 1 17:58:28 2001
@@ -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 (rmk@arm.linux.org.uk) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:18    [W:0.039 / U:0.280 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site