aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/fork.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2010-05-26 17:43:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-05-27 12:12:46 -0400
commit4dec2a91fd7e8815d730afbfdcf085cbf53433ac (patch)
treecd33cc793abf532d4ca212d09c1e8d3154a8b530 /kernel/fork.c
parentffdf91856c812646aa276711fa7e3ad80b00764a (diff)
fork/exit: move tty_kref_put() outside of __cleanup_signal()
tty_kref_put() has two callsites in copy_process() paths, 1. if copy_process() suceeds it is called before we copy signal->tty from parent 2. otherwise it is called from __cleanup_signal() under bad_fork_cleanup_signal: label In both cases tty_kref_put() is not right and unneeded because we don't have the balancing tty_kref_get(). Fortunately, this is harmless because this can only happen without CLONE_THREAD, and in this case signal->tty must be NULL. Remove tty_kref_put() from copy_process() and __cleanup_signal(), and change another caller of __cleanup_signal(), __exit_signal(), to call tty_kref_put() by hand. I hope this change makes sense by itself, but it is also needed to make ->signal refcountable. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Alan Cox <alan@linux.intel.com> Acked-by: Roland McGrath <roland@redhat.com> Cc: Greg KH <greg@kroah.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r--kernel/fork.c2
1 files changed, 0 insertions, 2 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index 2e9cc3139ec6..b7879ef6e7cd 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -892,7 +892,6 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
892void __cleanup_signal(struct signal_struct *sig) 892void __cleanup_signal(struct signal_struct *sig)
893{ 893{
894 thread_group_cputime_free(sig); 894 thread_group_cputime_free(sig);
895 tty_kref_put(sig->tty);
896 kmem_cache_free(signal_cachep, sig); 895 kmem_cache_free(signal_cachep, sig);
897} 896}
898 897
@@ -1263,7 +1262,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1263 p->nsproxy->pid_ns->child_reaper = p; 1262 p->nsproxy->pid_ns->child_reaper = p;
1264 1263
1265 p->signal->leader_pid = pid; 1264 p->signal->leader_pid = pid;
1266 tty_kref_put(p->signal->tty);
1267 p->signal->tty = tty_kref_get(current->signal->tty); 1265 p->signal->tty = tty_kref_get(current->signal->tty);
1268 attach_pid(p, PIDTYPE_PGID, task_pgrp(current)); 1266 attach_pid(p, PIDTYPE_PGID, task_pgrp(current));
1269 attach_pid(p, PIDTYPE_SID, task_session(current)); 1267 attach_pid(p, PIDTYPE_SID, task_session(current));