Commit 6ade99ec authored by Eric W. Biederman's avatar Eric W. Biederman

proc: Put thread_pid in release_task not proc_flush_pid

Oleg pointed out that in the unlikely event the kernel is compiled
with CONFIG_PROC_FS unset that release_task will now leak the pid.

Move the put_pid out of proc_flush_pid into release_task to fix this
and to guarantee I don't make that mistake again.

When possible it makes sense to keep get and put in the same function
so it can easily been seen how they pair up.

Fixes: 7bc3e6e5 ("proc: Use a list of inodes to flush from proc")
Reported-by: default avatarOleg Nesterov <oleg@redhat.com>
Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
parent 61e713bd
...@@ -3274,7 +3274,6 @@ static const struct inode_operations proc_tgid_base_inode_operations = { ...@@ -3274,7 +3274,6 @@ static const struct inode_operations proc_tgid_base_inode_operations = {
void proc_flush_pid(struct pid *pid) void proc_flush_pid(struct pid *pid)
{ {
proc_invalidate_siblings_dcache(&pid->inodes, &pid->lock); proc_invalidate_siblings_dcache(&pid->inodes, &pid->lock);
put_pid(pid);
} }
static struct dentry *proc_pid_instantiate(struct dentry * dentry, static struct dentry *proc_pid_instantiate(struct dentry * dentry,
......
...@@ -219,6 +219,7 @@ void release_task(struct task_struct *p) ...@@ -219,6 +219,7 @@ void release_task(struct task_struct *p)
write_unlock_irq(&tasklist_lock); write_unlock_irq(&tasklist_lock);
proc_flush_pid(thread_pid); proc_flush_pid(thread_pid);
put_pid(thread_pid);
release_thread(p); release_thread(p);
put_task_struct_rcu_user(p); put_task_struct_rcu_user(p);
......
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