Skip to contentSkip to conversation

latencytop: fix memory leak on latency proc file

PATCH New Hiroshi Shimamoto 1 participant 1 message Feb 14, 2008 Proc filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 latencytop: fix memory leak on latency proc file

From: Hiroshi Shimamoto <[email protected]>

At lstats_open(), calling get_proc_task() gets task struct, but it never put. put_task_struct() should be called when releasing.

---
 fs/proc/base.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
fs/proc/base.c +10 -1
index 1710b03..dc651a9 100644
@@ -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
Signature · 1 line
1.5.3.8