linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Patch: fix serial.c race prevention bug
@ 2001-11-01 18:02 Russell King
  0 siblings, 0 replies; only message in thread
From: Russell King @ 2001-11-01 18:02 UTC (permalink / raw)
  To: Alan Cox; +Cc: Linux Kernel List

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-11-01 18:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-01 18:02 Patch: fix serial.c race prevention bug Russell King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).