Declare the seq_operations and let procfs open and free the seq_file.
->proc_open() only decides whether to hide the addresses now.

Signed-off-by: Christian Brauner (Amutable) <[email protected]>
---
 kernel/module/procfs.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/kernel/module/procfs.c b/kernel/module/procfs.c
index 90712aa9dd13..a759bd916df7 100644
--- a/kernel/module/procfs.c
+++ b/kernel/module/procfs.c
@@ -117,31 +117,24 @@ static const struct seq_operations modules_op = {
 };
 
 /*
- * This also sets the "private" pointer to non-NULL if the
- * kernel pointers should be hidden (so you can just test
+ * procfs opens the seq_file. This sets the "private" pointer to non-NULL
+ * if the kernel pointers should be hidden (so you can just test
  * "m->private" to see if you should keep the values private).
  *
  * We use the same logic as for /proc/kallsyms.
  */
 static int modules_open(struct inode *inode, struct file *file)
 {
-       int err = seq_open(file, &modules_op);
+       struct seq_file *m = file->private_data;
 
-       if (!err) {
-               struct seq_file *m = file->private_data;
-
-               m->private = kallsyms_show_value(file->f_cred) ? NULL : (void 
*)8ul;
-       }
-
-       return err;
+       m->private = kallsyms_show_value(file->f_cred) ? NULL : (void *)8ul;
+       return 0;
 }
 
 static const struct proc_ops modules_proc_ops = {
        .proc_flags     = PROC_ENTRY_PERMANENT,
+       .proc_seq_ops   = &modules_op,
        .proc_open      = modules_open,
-       .proc_read      = seq_read,
-       .proc_lseek     = seq_lseek,
-       .proc_release   = seq_release,
 };
 
 static int __init proc_modules_init(void)

-- 
2.53.0


Reply via email to