Linux Kernel Mailing List | 6 May 2012 01:21

TTY: pdc_cons, fix regression in close

Gitweb:     http://git.kernel.org/linus/;a=commit;h=49a5f3cf6a956360bb43e5f8d0c592a8daea8ebd
Commit:     49a5f3cf6a956360bb43e5f8d0c592a8daea8ebd
Parent:     1c2f95480648ed7326ab2288ca0e2d35551db4be
Author:     Jiri Slaby <jslaby <at> suse.cz>
AuthorDate: Sat May 5 22:49:10 2012 +0200
Committer:  Linus Torvalds <torvalds <at> linux-foundation.org>
CommitDate: Sat May 5 16:21:21 2012 -0700

    TTY: pdc_cons, fix regression in close

    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 commit 5dd5bc40f3b6 ("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 <at> suse.cz>
    Reported-and-tested-by: Mikulas Patocka <mpatocka <at> redhat.com>
    Cc: Kyle McMartin <kyle <at> mcmartin.ca>
    Cc: Helge Deller <deller <at> gmx.de>
    Cc: "James E.J. Bottomley" <jejb <at> parisc-linux.org>
    Signed-off-by: Linus Torvalds <torvalds <at> linux-foundation.org>
---
 arch/parisc/kernel/pdc_cons.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

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
 <at>  <at>  -104,7 +104,7  <at>  <at>  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);
 	}
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Gmane