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);
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/