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 13:54:42 -0500	[thread overview]
Message-ID: <1095274482.2686.16.camel@deimos.microgate.com> (raw)
In-Reply-To: <20040915163051.GA9096@devserv.devel.redhat.com>

On Wed, 2004-09-15 at 11:30, Alan Cox wrote:
> On Wed, Sep 15, 2004 at 11:26:35AM -0500, Paul Fulghum wrote:
> > I tried this patch and can't change line disciplines.
> > The user program waits forever on ioctl(TIOCSETD).
> > I am going to add printk statements to
> 
> Is the tty currently in use - that implies maybe an ldisc leak
> 
> > Each line discipline has a refcount.
> > This single refcount is modified by all
> > entities using that line discipline.
> 
> Nope. tty->ldisc is a -copy- of the ldisc structure rather than a 
> pointer. It has always been that way

Got it.

Global ldisc array refcount is used to know
when an ldisc module can be unloaded.

Per tty ldisc refcount is used to know
when an ldisc can be switched.

The problem is that the per tty ldisc structure is being
initialized with the global ldisc array entry
including the global refcount.

So the per tty refcount starts non zero and
never goes to zero and can't be changed.

The per tty ldisc refcount must be initialized to zero 
after copying the global ldisc structure.

There are 6 places where this needs to be done:
3 in tty_set_ldisc
2 in release_dev
1 in initialize_tty_struct

Also:
Switching back to N_TTY ldisc in release_dev() of tty_io.c
takes a global ldisc reference (tty_ldisc_get) but
then frees the tty structure. This causes a reference
leak (global ldisc refcount) on N_TTY because there
is no corresponding tty_ldisc_put.


--
Paul Fulghum
paulkf@microgate.com



  reply	other threads:[~2004-09-15 18:56 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 [this message]
2004-09-15 20:08       ` Alan Cox
2004-09-15 20:23         ` Paul Fulghum
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=1095274482.2686.16.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