Declare the seq_operations and the size of the iterator and let procfs
open and free the seq_file of /proc/sysvipc/*. ->proc_open() only fills
in the iterator now and ->proc_release() drops the references it holds.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
ipc/util.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/ipc/util.c b/ipc/util.c
index 1737d776bc08..8ec3bc328657 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -894,13 +894,11 @@ static const struct seq_operations sysvipc_proc_seqops = {
.show = sysvipc_proc_show,
};
+/* procfs opened the seq_file and allocated @iter */
static int sysvipc_proc_open(struct inode *inode, struct file *file)
{
- struct ipc_proc_iter *iter;
-
- iter = __seq_open_private(file, &sysvipc_proc_seqops, sizeof(*iter));
- if (!iter)
- return -ENOMEM;
+ struct seq_file *m = file->private_data;
+ struct ipc_proc_iter *iter = m->private;
iter->iface = pde_data(inode);
iter->ns = get_ipc_ns(current->nsproxy->ipc_ns);@@ -915,14 +913,14 @@ static int sysvipc_proc_release(struct inode *inode, struct file *file)
struct ipc_proc_iter *iter = seq->private;
put_ipc_ns(iter->ns);
put_pid_ns(iter->pid_ns);
- return seq_release_private(inode, file);
+ return 0;
}
static const struct proc_ops sysvipc_proc_ops = {
.proc_flags = PROC_ENTRY_PERMANENT,
+ .proc_seq_ops = &sysvipc_proc_seqops,
+ .proc_state_size = sizeof(struct ipc_proc_iter),
.proc_open = sysvipc_proc_open,
- .proc_read = seq_read,
- .proc_lseek = seq_lseek,
.proc_release = sysvipc_proc_release,
};
#endif /* CONFIG_PROC_FS */
--
2.53.0