All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] TTY changes for 2.5.70
Date: Thu, 5 Jun 2003 15:28:06 -0700	[thread overview]
Message-ID: <20030605222806.GC7717@kroah.com> (raw)
In-Reply-To: <20030605222753.GB7717@kroah.com>

ChangeSet 1.1314, 2003/06/05 14:21:57-07:00, greg@kroah.com

TTY: add a release function for tty_class devices.

This fixes a race with looking at files in /sys/class/tty/ and removing a
tty device.


 drivers/char/tty_io.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletion(-)


diff -Nru a/drivers/char/tty_io.c b/drivers/char/tty_io.c
--- a/drivers/char/tty_io.c	Thu Jun  5 15:21:07 2003
+++ b/drivers/char/tty_io.c	Thu Jun  5 15:21:07 2003
@@ -2114,6 +2114,12 @@
 }
 static CLASS_DEVICE_ATTR(dev, S_IRUGO, show_dev, NULL);
 
+static void release_tty_dev(struct class_device *class_dev)
+{
+	struct tty_dev *tty_dev = to_tty_dev(class_dev);
+	kfree(tty_dev);
+}
+
 static void tty_add_class_device(char *name, dev_t dev, struct device *device)
 {
 	struct tty_dev *tty_dev = NULL;
@@ -2134,6 +2140,7 @@
 
 	tty_dev->class_dev.dev = device;
 	tty_dev->class_dev.class = &tty_class;
+	tty_dev->class_dev.release = &release_tty_dev;
 	snprintf(tty_dev->class_dev.class_id, BUS_ID_SIZE, "%s", temp);
 	retval = class_device_register(&tty_dev->class_dev);
 	if (retval)
@@ -2167,7 +2174,6 @@
 		list_del(&tty_dev->node);
 		spin_unlock(&tty_dev_list_lock);
 		class_device_unregister(&tty_dev->class_dev);
-		kfree(tty_dev);
 	} else {
 		spin_unlock(&tty_dev_list_lock);
 	}

  parent reply	other threads:[~2003-06-05 22:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-05 22:27 [BK PATCH] TTY changes for 2.5.70 Greg KH
     [not found] ` <20030605222753.GB7717@kroah.com>
2003-06-05 22:28   ` Greg KH [this message]
2003-06-05 22:28     ` [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=20030605222806.GC7717@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.