[PATCH] copy_process: cleanup bad_fork_cleanup_sighand

The only caller of exit_sighand(tsk) is copy_process's error path.  We can
call __exit_sighand() directly and kill exit_sighand().

This 'tsk' was not yet registered in pid_hash[] or init_task.tasks, it has no
external references, nobody can see it, and

	IF (clone_flags & CLONE_SIGHAND)
		At least 'current' has a reference to ->sighand, this
		means atomic_dec_and_test(sighand->count) can't be true.

	ELSE
		Nobody can see this ->sighand, this means we can free it
		without any locking.

Signed-off-by: Oleg Nesterov <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Acked-by: "Paul E. McKenney" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
Oleg Nesterov 2006-03-28 16:11:14 -08:00 • committed by Linus Torvalds
commit 7001510d0c
3 changed files with 2 additions and 16 deletions

View file

@ -336,20 +336,6 @@ void __exit_sighand(struct task_struct *tsk)
kmem_cache_free(sighand_cachep, sighand);
}
void exit_sighand(struct task_struct *tsk)
{
write_lock_irq(&tasklist_lock);
rcu_read_lock();
if (tsk->sighand != NULL) {
struct sighand_struct *sighand = rcu_dereference(tsk->sighand);
spin_lock(&sighand->siglock);
__exit_sighand(tsk);
spin_unlock(&sighand->siglock);
}
rcu_read_unlock();
write_unlock_irq(&tasklist_lock);
}
/*
* This function expects the tasklist_lock write-locked.
*/