Commit 63ac2a63 authored by Linus Torvalds's avatar Linus Torvalds

Avoid memory leak on fork() failure path.

Noticed by Martin Schwidefsky <schwidefsky@de.ibm.com>
parent ea3d5d12
......@@ -72,15 +72,8 @@ int nr_processes(void)
return total;
}
void __put_task_struct(struct task_struct *tsk)
static void free_task_struct(struct task_struct *tsk)
{
WARN_ON(!(tsk->state & (TASK_DEAD | TASK_ZOMBIE)));
WARN_ON(atomic_read(&tsk->usage));
WARN_ON(tsk == current);
security_task_free(tsk);
free_uid(tsk->user);
/*
* The task cache is effectively disabled right now.
* Do we want it? The slab cache already has per-cpu
......@@ -103,6 +96,17 @@ void __put_task_struct(struct task_struct *tsk)
}
}
void __put_task_struct(struct task_struct *tsk)
{
WARN_ON(!(tsk->state & (TASK_DEAD | TASK_ZOMBIE)));
WARN_ON(atomic_read(&tsk->usage));
WARN_ON(tsk == current);
security_task_free(tsk);
free_uid(tsk->user);
free_task_struct(tsk);
}
void add_wait_queue(wait_queue_head_t *q, wait_queue_t * wait)
{
unsigned long flags;
......@@ -1034,7 +1038,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
atomic_dec(&p->user->processes);
free_uid(p->user);
bad_fork_free:
put_task_struct(p);
free_task_struct(p);
goto fork_out;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment