Merge tag 'ktest-v5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
[linux-2.6-microblaze.git] / drivers / tty / tty_io.c
index 9f8b9a5..8034489 100644 (file)
@@ -208,7 +208,7 @@ void tty_add_file(struct tty_struct *tty, struct file *file)
        spin_unlock(&tty->files_lock);
 }
 
-/**
+/*
  * tty_free_file - free file->private_data
  *
  * This shall be used only for fail path handling when tty_add_file was not
@@ -514,8 +514,6 @@ static const struct file_operations hung_up_tty_fops = {
 static DEFINE_SPINLOCK(redirect_lock);
 static struct file *redirect;
 
-extern void tty_sysctl_init(void);
-
 /**
  *     tty_wakeup      -       request more data
  *     @tty: terminal
@@ -545,6 +543,7 @@ EXPORT_SYMBOL_GPL(tty_wakeup);
 /**
  *     __tty_hangup            -       actual handler for hangup events
  *     @tty: tty device
+ *     @exit_session: if non-zero, signal all foreground group processes
  *
  *     This can be called by a "kworker" kernel thread.  That is process
  *     synchronous but doesn't hold any locks, so we need to make sure we
@@ -1067,7 +1066,7 @@ ssize_t redirected_tty_write(struct file *file, const char __user *buf,
        return tty_write(file, buf, count, ppos);
 }
 
-/**
+/*
  *     tty_send_xchar  -       send priority character
  *
  *     Send a high priority character to the tty even if stopped
@@ -1145,6 +1144,7 @@ static ssize_t tty_line_name(struct tty_driver *driver, int index, char *p)
 /**
  *     tty_driver_lookup_tty() - find an existing tty, if any
  *     @driver: the driver for the tty
+ *     @file:   file object
  *     @idx:    the minor number
  *
  *     Return the tty, if found. If not found, return NULL or ERR_PTR() if the
@@ -1496,6 +1496,8 @@ EXPORT_SYMBOL(tty_kref_put);
 
 /**
  *     release_tty             -       release tty structure memory
+ *     @tty: tty device release
+ *     @idx: index of the tty device release
  *
  *     Release both @tty and a possible linked partner (think pty pair),
  *     and decrement the refcount of the backing module.
@@ -2897,10 +2899,14 @@ void __do_SAK(struct tty_struct *tty)
        struct task_struct *g, *p;
        struct pid *session;
        int             i;
+       unsigned long flags;
 
        if (!tty)
                return;
-       session = tty->session;
+
+       spin_lock_irqsave(&tty->ctrl_lock, flags);
+       session = get_pid(tty->session);
+       spin_unlock_irqrestore(&tty->ctrl_lock, flags);
 
        tty_ldisc_flush(tty);
 
@@ -2932,6 +2938,7 @@ void __do_SAK(struct tty_struct *tty)
                task_unlock(p);
        } while_each_thread(g, p);
        read_unlock(&tasklist_lock);
+       put_pid(session);
 #endif
 }
 
@@ -2965,7 +2972,7 @@ static struct device *tty_get_device(struct tty_struct *tty)
 }
 
 
-/**
+/*
  *     alloc_tty_struct
  *
  *     This subroutine allocates and initializes a tty structure.