public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Russell King <rmk@arm.linux.org.uk>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Linux Kernel List <linux-kernel@vger.kernel.org>
Subject: Patch: fix serial.c race prevention bug
Date: Thu, 1 Nov 2001 18:02:45 +0000	[thread overview]
Message-ID: <20011101180245.D10819@flint.arm.linux.org.uk> (raw)

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


                 reply	other threads:[~2001-11-01 18:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20011101180245.D10819@flint.arm.linux.org.uk \
    --to=rmk@arm.linux.org.uk \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox