public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Fulghum <paulkf@microgate.com>
To: Alan Cox <alan@redhat.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@osdl.org>
Subject: Re: PATCH: tty locking for 2.6.9rc2
Date: 15 Sep 2004 15:23:19 -0500	[thread overview]
Message-ID: <1095279799.2958.11.camel@deimos.microgate.com> (raw)
In-Reply-To: <20040915200856.GA8000@devserv.devel.redhat.com>

Alan:

Here is a patch against your last patch that clears
up both the per tty refcount initialization and
the remove_dev() global refcount leak.

I've tested it and it seems to work.

The patch is not meant to be applied and
is just for your information in deciding
how you want the final code to look.

--- linux-2.6.9/drivers/char/tty_io.c	2004-09-15 15:19:58.044611590 -0500
+++ linux-2.6.9-mg/drivers/char/tty_io.c	2004-09-15 15:19:34.690680997 -0500
@@ -288,6 +288,7 @@
 	}
 	else
 		ld = NULL;
+	if (ld) printk("tty_ldisc_get ld=%p refcount=%d\n", ld, ld->refcount);
 	spin_unlock_irqrestore(&tty_ldisc_lock, flags);
 	return ld;
 }
@@ -307,6 +308,7 @@
 	if(ld->refcount == 0)
 		BUG();
 	ld->refcount --;
+	printk("tty_ldisc_put ld=%p refcount=%d\n", ld, ld->refcount);
 	module_put(ld->owner);
 	spin_unlock_irqrestore(&tty_ldisc_lock, flags);
 }
@@ -497,6 +499,7 @@
 
 	/* Now set up the new line discipline. */
 	tty->ldisc = *ld;
+	tty->ldisc.refcount = 0;
 	tty->termios->c_line = ldisc;
 	if (tty->ldisc.open)
 		retval = (tty->ldisc.open)(tty);
@@ -504,11 +507,13 @@
 		tty_ldisc_put(ldisc);
 		/* There is an outstanding reference here so this is safe */
 		tty->ldisc = *tty_ldisc_get(o_ldisc.num);
+		tty->ldisc.refcount = 0;
 		tty->termios->c_line = tty->ldisc.num;
 		if (tty->ldisc.open && (tty->ldisc.open(tty) < 0)) {
 			tty_ldisc_put(o_ldisc.num);
 			/* This driver is always present */
 			tty->ldisc = *tty_ldisc_get(N_TTY);
+			tty->ldisc.refcount = 0;
 			tty->termios->c_line = N_TTY;
 			if (tty->ldisc.open) {
 				int r = tty->ldisc.open(tty);
@@ -1567,15 +1572,15 @@
 	/*
 	 *	Switch the line discipline back
 	 */
-	tty->ldisc = *tty_ldisc_get(N_TTY);
-	tty->termios->c_line = N_TTY;
+//	tty->ldisc = *tty_ldisc_get(N_TTY);
+//	tty->termios->c_line = N_TTY;
 	if (o_tty) {
 		/* FIXME: could o_tty be in setldisc here ? */
 		clear_bit(TTY_LDISC, &o_tty->flags);
 		if (o_tty->ldisc.close)
 			(o_tty->ldisc.close)(o_tty);
 		tty_ldisc_put(o_tty->ldisc.num);
-		o_tty->ldisc = *tty_ldisc_get(N_TTY);
+//		o_tty->ldisc = *tty_ldisc_get(N_TTY);
 	}
 
 	/*
@@ -2466,6 +2471,7 @@
 	memset(tty, 0, sizeof(struct tty_struct));
 	tty->magic = TTY_MAGIC;
 	tty->ldisc = *tty_ldisc_get(N_TTY);
+	tty->ldisc.refcount = 0;
 	tty->pgrp = -1;
 	tty->flip.char_buf_ptr = tty->flip.char_buf;
 	tty->flip.flag_buf_ptr = tty->flip.flag_buf;

Thanks,
Paul
 
--
Paul Fulghum
paulkf@microgate.com



  reply	other threads:[~2004-09-15 20:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-14 16:34 PATCH: tty locking for 2.6.9rc2 Alan Cox
2004-09-15 16:26 ` Paul Fulghum
2004-09-15 16:30   ` Alan Cox
2004-09-15 18:54     ` Paul Fulghum
2004-09-15 20:08       ` Alan Cox
2004-09-15 20:23         ` Paul Fulghum [this message]
2004-09-15 20:40           ` Alan Cox
2004-09-15 20:53             ` Paul Fulghum
  -- strict thread matches above, loose matches on Subject: below --
2004-09-24  0:36 Ulisses

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=1095279799.2958.11.camel@deimos.microgate.com \
    --to=paulkf@microgate.com \
    --cc=akpm@osdl.org \
    --cc=alan@redhat.com \
    --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