From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] TTY changes for 2.5.58
Date: Tue, 14 Jan 2003 17:14:10 -0800 [thread overview]
Message-ID: <20030115011409.GB18283@kroah.com> (raw)
In-Reply-To: <20030115011312.GA18283@kroah.com>
ChangeSet 1.1025, 2003/01/14 16:51:58-08:00, greg@kroah.com
TTY: add module reference counting for tty drivers.
Note, there are still races with unloading modules, this patch
does not fix that...
diff -Nru a/drivers/char/tty_io.c b/drivers/char/tty_io.c
--- a/drivers/char/tty_io.c Tue Jan 14 17:07:05 2003
+++ b/drivers/char/tty_io.c Tue Jan 14 17:07:05 2003
@@ -833,6 +833,11 @@
* and locked termios may be retained.)
*/
+ if (!try_module_get(driver->owner)) {
+ retval = -ENODEV;
+ goto end_init;
+ }
+
o_tty = NULL;
tp = o_tp = NULL;
ltp = o_ltp = NULL;
@@ -991,6 +996,7 @@
free_tty_struct(tty);
fail_no_mem:
+ module_put(driver->owner);
retval = -ENOMEM;
goto end_init;
@@ -1033,6 +1039,7 @@
tty->magic = 0;
(*tty->driver.refcount)--;
list_del(&tty->tty_files);
+ module_put(tty->driver.owner);
free_tty_struct(tty);
}
diff -Nru a/include/linux/tty_driver.h b/include/linux/tty_driver.h
--- a/include/linux/tty_driver.h Tue Jan 14 17:07:05 2003
+++ b/include/linux/tty_driver.h Tue Jan 14 17:07:05 2003
@@ -120,6 +120,7 @@
struct tty_driver {
int magic; /* magic number for this structure */
+ struct module *owner;
const char *driver_name;
const char *name;
int name_base; /* offset of printed name */
next prev parent reply other threads:[~2003-01-15 1:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-15 1:13 [BK PATCH] TTY changes for 2.5.58 Greg KH
2003-01-15 1:14 ` Greg KH [this message]
2003-01-15 1:14 ` [PATCH] " Greg KH
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=20030115011409.GB18283@kroah.com \
--to=greg@kroah.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