public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Fulghum <paulkf@microgate.com>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Andrew Morton <akpm@osdl.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] Introduce tty_unregister_ldisc()
Date: Wed, 01 Jun 2005 08:51:52 -0500	[thread overview]
Message-ID: <1117633912.2921.15.camel@deimos.microgate.com> (raw)
In-Reply-To: <1117597088.5888.18.camel@at2.pipehead.org>

The following patch would be more appropriate than
my last suggestion for the case of trying to register
a ldisc driver to an occupied slot.

It does not make sense to allow an existing
registered driver to be overwritten, even
if the refcount is zero.

This *should* not happen with unique ldisc numbers,
but it seems like a reasonable check. Even if
Alexey's patch is applied, this would be a
reasonable check to integrate.

-- 
Paul Fulghum
paulkf@microgate.com

--- linux-2.6.11/drivers/char/tty_io.c	2005-03-02 01:38:10.000000000 -0600
+++ b/drivers/char/tty_io.c	2005-06-01 08:34:05.000000000 -0500
@@ -263,10 +263,14 @@ int tty_register_ldisc(int disc, struct 
 	
 	spin_lock_irqsave(&tty_ldisc_lock, flags);
 	if (new_ldisc) {
-		tty_ldiscs[disc] = *new_ldisc;
-		tty_ldiscs[disc].num = disc;
-		tty_ldiscs[disc].flags |= LDISC_FLAG_DEFINED;
-		tty_ldiscs[disc].refcount = 0;
+		if (tty_ldiscs[disc].flags & LDISC_FLAG_DEFINED)
+			ret = -EBUSY;
+		else {
+			tty_ldiscs[disc] = *new_ldisc;
+			tty_ldiscs[disc].num = disc;
+			tty_ldiscs[disc].flags |= LDISC_FLAG_DEFINED;
+			tty_ldiscs[disc].refcount = 0;
+		}
 	} else {
 		if(tty_ldiscs[disc].refcount)
 			ret = -EBUSY;



  reply	other threads:[~2005-06-01 13:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-31 19:56 [PATCH 1/2] Introduce tty_unregister_ldisc() Alexey Dobriyan
2005-05-31 22:28 ` Paul Fulghum
2005-06-01  3:38   ` Paul Fulghum
2005-06-01 13:51     ` Paul Fulghum [this message]
2005-06-01  4:39   ` Greg KH
2005-06-01  5:42   ` Christoph Hellwig
2005-06-01 15:22     ` Alexey Dobriyan
  -- strict thread matches above, loose matches on Subject: below --
2005-06-15 21:40 Alexey Dobriyan

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=1117633912.2921.15.camel@deimos.microgate.com \
    --to=paulkf@microgate.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@osdl.org \
    --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