The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: gregkh@linuxfoundation.org
Cc: gmsof@tuxicoman.be, torvalds@linux-foundation.org,
	linux-kernel@vger.kernel.org, jirislaby@gmail.com,
	Kyle McMartin <kyle@mcmartin.ca>, Helge Deller <deller@gmx.de>,
	"James E.J. Bottomley" <jejb@parisc-linux.org>
Subject: [PATCH 1/1] TTY: pdc_cons, fix regression in close
Date: Sat,  5 May 2012 22:49:10 +0200	[thread overview]
Message-ID: <1336250950-24645-1-git-send-email-jslaby@suse.cz> (raw)
In-Reply-To: <Pine.LNX.4.64.1205051443520.2623@file.rdu.redhat.com>

The test in pdc_console_tty_close '!tty->count' was always wrong
because tty->count is decremented after tty->ops->close is called and
thus can never be zero. Hence the 'then' branch was never executed and
the timer never deleted.

This did not matter until 5dd5bc40f3b6e0ccdaad948dbadc94ad0906cb25
(TTY: pdc_cons, use tty_port). There we needed to set TTY in tty_port
to NULL, but this never happened due to the bug above.

So change the test to really trigger at the last close by changing the
condition to 'tty->count == 1'.

Well, the driver should not touch tty->count at all. It should use
tty_port->count and count open count there itself.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Reported-and-tested-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Helge Deller <deller@gmx.de>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
---
 arch/parisc/kernel/pdc_cons.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c
index 4f00459..0b33933 100644
--- a/arch/parisc/kernel/pdc_cons.c
+++ b/arch/parisc/kernel/pdc_cons.c
@@ -104,7 +104,7 @@ static int pdc_console_tty_open(struct tty_struct *tty, struct file *filp)
 
 static void pdc_console_tty_close(struct tty_struct *tty, struct file *filp)
 {
-	if (!tty->count) {
+	if (tty->count == 1) {
 		del_timer_sync(&pdc_console_timer);
 		tty_port_tty_set(&tty_port, NULL);
 	}
-- 
1.7.9.2



  reply	other threads:[~2012-05-05 20:49 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-05  2:58 [PATCH] Fix compile failure on PA-RISC Mikulas Patocka
2012-05-05  3:04 ` [PATCH] Revert 5dd5bc40f3b6e0ccdaad948dbadc94ad0906cb25 Mikulas Patocka
2012-05-05  7:39   ` Jiri Slaby
2012-05-05 18:44     ` Mikulas Patocka
2012-05-05 20:49       ` Jiri Slaby [this message]
2012-05-05  6:55 ` [PATCH] Fix compile failure on PA-RISC Rolf Eike Beer
2012-05-05 17:09   ` Linus Torvalds
2012-05-05 18:55   ` Mikulas Patocka
2012-05-05 20:09     ` John David Anglin
2012-05-05 21:24       ` Helge Deller
2012-05-06  7:57         ` James Bottomley
2012-05-05 10:58 ` Alan Cox
2012-05-05 18:53   ` Mikulas Patocka
2012-05-05 18:55     ` Linus Torvalds
2012-05-05 22:00       ` Rolf Eike Beer
2012-05-09  3:20       ` Mikulas Patocka
2012-05-09 12:01         ` Alan Cox
2012-05-09 17:51         ` Linus Torvalds
2012-05-10  9:24           ` Geert Uytterhoeven
2012-05-06 12:24     ` Alan Cox
2012-05-09 17:38       ` Grant Grundler
2012-05-10 11:40         ` Alan Cox

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=1336250950-24645-1-git-send-email-jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=deller@gmx.de \
    --cc=gmsof@tuxicoman.be \
    --cc=gregkh@linuxfoundation.org \
    --cc=jejb@parisc-linux.org \
    --cc=jirislaby@gmail.com \
    --cc=kyle@mcmartin.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.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