|
@@ -138,9 +138,6 @@ LIST_HEAD(tty_drivers); /* linked list of tty drivers */
|
|
|
/* Mutex to protect creating and releasing a tty */
|
|
|
DEFINE_MUTEX(tty_mutex);
|
|
|
|
|
|
-/* Spinlock to protect the tty->tty_files list */
|
|
|
-DEFINE_SPINLOCK(tty_files_lock);
|
|
|
-
|
|
|
static ssize_t tty_read(struct file *, char __user *, size_t, loff_t *);
|
|
|
static ssize_t tty_write(struct file *, const char __user *, size_t, loff_t *);
|
|
|
ssize_t redirected_tty_write(struct file *, const char __user *,
|
|
@@ -202,9 +199,9 @@ void tty_add_file(struct tty_struct *tty, struct file *file)
|
|
|
priv->tty = tty;
|
|
|
priv->file = file;
|
|
|
|
|
|
- spin_lock(&tty_files_lock);
|
|
|
+ spin_lock(&tty->files_lock);
|
|
|
list_add(&priv->list, &tty->tty_files);
|
|
|
- spin_unlock(&tty_files_lock);
|
|
|
+ spin_unlock(&tty->files_lock);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -225,10 +222,11 @@ void tty_free_file(struct file *file)
|
|
|
static void tty_del_file(struct file *file)
|
|
|
{
|
|
|
struct tty_file_private *priv = file->private_data;
|
|
|
+ struct tty_struct *tty = priv->tty;
|
|
|
|
|
|
- spin_lock(&tty_files_lock);
|
|
|
+ spin_lock(&tty->files_lock);
|
|
|
list_del(&priv->list);
|
|
|
- spin_unlock(&tty_files_lock);
|
|
|
+ spin_unlock(&tty->files_lock);
|
|
|
tty_free_file(file);
|
|
|
}
|
|
|
|
|
@@ -286,11 +284,11 @@ static int check_tty_count(struct tty_struct *tty, const char *routine)
|
|
|
struct list_head *p;
|
|
|
int count = 0;
|
|
|
|
|
|
- spin_lock(&tty_files_lock);
|
|
|
+ spin_lock(&tty->files_lock);
|
|
|
list_for_each(p, &tty->tty_files) {
|
|
|
count++;
|
|
|
}
|
|
|
- spin_unlock(&tty_files_lock);
|
|
|
+ spin_unlock(&tty->files_lock);
|
|
|
if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
|
|
|
tty->driver->subtype == PTY_TYPE_SLAVE &&
|
|
|
tty->link && tty->link->count)
|
|
@@ -713,7 +711,7 @@ static void __tty_hangup(struct tty_struct *tty, int exit_session)
|
|
|
workqueue with the lock held */
|
|
|
check_tty_count(tty, "tty_hangup");
|
|
|
|
|
|
- spin_lock(&tty_files_lock);
|
|
|
+ spin_lock(&tty->files_lock);
|
|
|
/* This breaks for file handles being sent over AF_UNIX sockets ? */
|
|
|
list_for_each_entry(priv, &tty->tty_files, list) {
|
|
|
filp = priv->file;
|
|
@@ -725,7 +723,7 @@ static void __tty_hangup(struct tty_struct *tty, int exit_session)
|
|
|
__tty_fasync(-1, filp, 0); /* can't block */
|
|
|
filp->f_op = &hung_up_tty_fops;
|
|
|
}
|
|
|
- spin_unlock(&tty_files_lock);
|
|
|
+ spin_unlock(&tty->files_lock);
|
|
|
|
|
|
refs = tty_signal_session_leader(tty, exit_session);
|
|
|
/* Account for the p->signal references we killed */
|
|
@@ -1637,9 +1635,9 @@ static void release_one_tty(struct work_struct *work)
|
|
|
tty_driver_kref_put(driver);
|
|
|
module_put(owner);
|
|
|
|
|
|
- spin_lock(&tty_files_lock);
|
|
|
+ spin_lock(&tty->files_lock);
|
|
|
list_del_init(&tty->tty_files);
|
|
|
- spin_unlock(&tty_files_lock);
|
|
|
+ spin_unlock(&tty->files_lock);
|
|
|
|
|
|
put_pid(tty->pgrp);
|
|
|
put_pid(tty->session);
|
|
@@ -3176,6 +3174,7 @@ struct tty_struct *alloc_tty_struct(struct tty_driver *driver, int idx)
|
|
|
mutex_init(&tty->atomic_write_lock);
|
|
|
spin_lock_init(&tty->ctrl_lock);
|
|
|
spin_lock_init(&tty->flow_lock);
|
|
|
+ spin_lock_init(&tty->files_lock);
|
|
|
INIT_LIST_HEAD(&tty->tty_files);
|
|
|
INIT_WORK(&tty->SAK_work, do_SAK_work);
|
|
|
|