summaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-07-01 21:32:19 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2018-07-01 21:32:19 +0200
commit4a770e638f531d078b580a5a24412c5e5f8f7ddb (patch)
treefde3fdcf9f6fc3bbafaa8ed0964f689cb5b79c57 /fs/proc
parentMerge tag 'staging-4.18-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git... (diff)
parentproc: add proc_seq_release (diff)
downloadlinux-4a770e638f531d078b580a5a24412c5e5f8f7ddb.tar.xz
linux-4a770e638f531d078b580a5a24412c5e5f8f7ddb.zip
Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs fix from Al Viro: "Followup to procfs-seq_file series this window" This fixes a memory leak by making sure that proc seq files release any private data on close. The 'proc_seq_open' has to be properly paired with 'proc_seq_release' that releases the extra private data. * 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: proc: add proc_seq_release
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/generic.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 6ac1c92997ea..bb1c1625b158 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -564,11 +564,20 @@ static int proc_seq_open(struct inode *inode, struct file *file)
return seq_open(file, de->seq_ops);
}
+static int proc_seq_release(struct inode *inode, struct file *file)
+{
+ struct proc_dir_entry *de = PDE(inode);
+
+ if (de->state_size)
+ return seq_release_private(inode, file);
+ return seq_release(inode, file);
+}
+
static const struct file_operations proc_seq_fops = {
.open = proc_seq_open,
.read = seq_read,
.llseek = seq_lseek,
- .release = seq_release,
+ .release = proc_seq_release,
};
struct proc_dir_entry *proc_create_seq_private(const char *name, umode_t mode,