]> err.no Git - linux-2.6/commitdiff
latencytop: fix memory leak on latency proc file
authorHiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Thu, 14 Feb 2008 18:27:00 +0000 (10:27 -0800)
committerIngo Molnar <mingo@elte.hu>
Mon, 25 Feb 2008 15:34:17 +0000 (16:34 +0100)
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>
fs/proc/base.c

index 989e3078d7af5344fcbd2e65dd09b2d46e4fee63..85e06e4980780163740790e9d160a69bab6cfc7e 100644 (file)
@@ -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)
 {
@@ -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