diff options
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/tty_io.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index a7b915516d7b..39db186d5c5b 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -153,8 +153,7 @@ int tty_ioctl(struct inode * inode, struct file * file, | |||
153 | unsigned int cmd, unsigned long arg); | 153 | unsigned int cmd, unsigned long arg); |
154 | static int tty_fasync(int fd, struct file * filp, int on); | 154 | static int tty_fasync(int fd, struct file * filp, int on); |
155 | static void release_tty(struct tty_struct *tty, int idx); | 155 | static void release_tty(struct tty_struct *tty, int idx); |
156 | static struct pid *__proc_set_tty(struct task_struct *tsk, | 156 | static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty); |
157 | struct tty_struct *tty); | ||
158 | 157 | ||
159 | /** | 158 | /** |
160 | * alloc_tty_struct - allocate a tty object | 159 | * alloc_tty_struct - allocate a tty object |
@@ -1532,10 +1531,9 @@ void disassociate_ctty(int on_exit) | |||
1532 | } | 1531 | } |
1533 | 1532 | ||
1534 | spin_lock_irq(¤t->sighand->siglock); | 1533 | spin_lock_irq(¤t->sighand->siglock); |
1535 | tty_pgrp = current->signal->tty_old_pgrp; | 1534 | put_pid(current->signal->tty_old_pgrp); |
1536 | current->signal->tty_old_pgrp = NULL; | 1535 | current->signal->tty_old_pgrp = NULL; |
1537 | spin_unlock_irq(¤t->sighand->siglock); | 1536 | spin_unlock_irq(¤t->sighand->siglock); |
1538 | put_pid(tty_pgrp); | ||
1539 | 1537 | ||
1540 | mutex_lock(&tty_mutex); | 1538 | mutex_lock(&tty_mutex); |
1541 | /* It is possible that do_tty_hangup has free'd this tty */ | 1539 | /* It is possible that do_tty_hangup has free'd this tty */ |
@@ -2506,7 +2504,6 @@ static int tty_open(struct inode * inode, struct file * filp) | |||
2506 | int index; | 2504 | int index; |
2507 | dev_t device = inode->i_rdev; | 2505 | dev_t device = inode->i_rdev; |
2508 | unsigned short saved_flags = filp->f_flags; | 2506 | unsigned short saved_flags = filp->f_flags; |
2509 | struct pid *old_pgrp; | ||
2510 | 2507 | ||
2511 | nonseekable_open(inode, filp); | 2508 | nonseekable_open(inode, filp); |
2512 | 2509 | ||
@@ -2600,17 +2597,15 @@ got_driver: | |||
2600 | goto retry_open; | 2597 | goto retry_open; |
2601 | } | 2598 | } |
2602 | 2599 | ||
2603 | old_pgrp = NULL; | ||
2604 | mutex_lock(&tty_mutex); | 2600 | mutex_lock(&tty_mutex); |
2605 | spin_lock_irq(¤t->sighand->siglock); | 2601 | spin_lock_irq(¤t->sighand->siglock); |
2606 | if (!noctty && | 2602 | if (!noctty && |
2607 | current->signal->leader && | 2603 | current->signal->leader && |
2608 | !current->signal->tty && | 2604 | !current->signal->tty && |
2609 | tty->session == NULL) | 2605 | tty->session == NULL) |
2610 | old_pgrp = __proc_set_tty(current, tty); | 2606 | __proc_set_tty(current, tty); |
2611 | spin_unlock_irq(¤t->sighand->siglock); | 2607 | spin_unlock_irq(¤t->sighand->siglock); |
2612 | mutex_unlock(&tty_mutex); | 2608 | mutex_unlock(&tty_mutex); |
2613 | put_pid(old_pgrp); | ||
2614 | return 0; | 2609 | return 0; |
2615 | } | 2610 | } |
2616 | 2611 | ||
@@ -3835,9 +3830,8 @@ void proc_clear_tty(struct task_struct *p) | |||
3835 | spin_unlock_irq(&p->sighand->siglock); | 3830 | spin_unlock_irq(&p->sighand->siglock); |
3836 | } | 3831 | } |
3837 | 3832 | ||
3838 | static struct pid *__proc_set_tty(struct task_struct *tsk, struct tty_struct *tty) | 3833 | static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty) |
3839 | { | 3834 | { |
3840 | struct pid *old_pgrp; | ||
3841 | if (tty) { | 3835 | if (tty) { |
3842 | /* We should not have a session or pgrp to here but.... */ | 3836 | /* We should not have a session or pgrp to here but.... */ |
3843 | put_pid(tty->session); | 3837 | put_pid(tty->session); |
@@ -3845,21 +3839,16 @@ static struct pid *__proc_set_tty(struct task_struct *tsk, struct tty_struct *tt | |||
3845 | tty->session = get_pid(task_session(tsk)); | 3839 | tty->session = get_pid(task_session(tsk)); |
3846 | tty->pgrp = get_pid(task_pgrp(tsk)); | 3840 | tty->pgrp = get_pid(task_pgrp(tsk)); |
3847 | } | 3841 | } |
3848 | old_pgrp = tsk->signal->tty_old_pgrp; | 3842 | put_pid(tsk->signal->tty_old_pgrp); |
3849 | tsk->signal->tty = tty; | 3843 | tsk->signal->tty = tty; |
3850 | tsk->signal->tty_old_pgrp = NULL; | 3844 | tsk->signal->tty_old_pgrp = NULL; |
3851 | return old_pgrp; | ||
3852 | } | 3845 | } |
3853 | 3846 | ||
3854 | void proc_set_tty(struct task_struct *tsk, struct tty_struct *tty) | 3847 | void proc_set_tty(struct task_struct *tsk, struct tty_struct *tty) |
3855 | { | 3848 | { |
3856 | struct pid *old_pgrp; | ||
3857 | |||
3858 | spin_lock_irq(&tsk->sighand->siglock); | 3849 | spin_lock_irq(&tsk->sighand->siglock); |
3859 | old_pgrp = __proc_set_tty(tsk, tty); | 3850 | __proc_set_tty(tsk, tty); |
3860 | spin_unlock_irq(&tsk->sighand->siglock); | 3851 | spin_unlock_irq(&tsk->sighand->siglock); |
3861 | |||
3862 | put_pid(old_pgrp); | ||
3863 | } | 3852 | } |
3864 | 3853 | ||
3865 | struct tty_struct *get_current_tty(void) | 3854 | struct tty_struct *get_current_tty(void) |