Skip to content

Commit

Permalink
latencytop: fix memory leak on latency proc file
Browse files Browse the repository at this point in the history
At lstats_open(), calling get_proc_task() gets task struct, but it never put.
put_task_struct() should be called when releasing.

Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Hiroshi Shimamoto authored and Ingo Molnar committed Feb 25, 2008
1 parent ae00278 commit d6643d1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,15 @@ static int lstats_open(struct inode *inode, struct file *file)
return ret;
}

static int lstats_release(struct inode *inode, struct file *file)
{
struct seq_file *m = file->private_data;
struct task_struct *task = m->private;

put_task_struct(task);
return single_release(inode, file);
}

static ssize_t lstats_write(struct file *file, const char __user *buf,
size_t count, loff_t *offs)
{
Expand All @@ -378,7 +387,7 @@ static const struct file_operations proc_lstats_operations = {
.read = seq_read,
.write = lstats_write,
.llseek = seq_lseek,
.release = single_release,
.release = lstats_release,
};

#endif
Expand Down

0 comments on commit d6643d1

Please sign in to comment.