fs/proc/task_nommu.c: change maps_open() to use __seq_open_private()
authorOleg Nesterov <[email protected]>
Thu, 9 Oct 2014 22:25:45 +0000 (15:25 -0700)
committerLinus Torvalds <[email protected]>
Fri, 10 Oct 2014 02:25:49 +0000 (22:25 -0400)
Cleanup and preparation. maps_open() can use __seq_open_private()
like proc_maps_open() does.

[[email protected]: deuglify]
Signed-off-by: Oleg Nesterov <[email protected]>
Cc: Kirill A. Shutemov <[email protected]>
Cc: Cyrill Gorcunov <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Acked-by: Greg Ungerer <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
fs/proc/task_nommu.c

index 678455d2d6839e9ab0df0909905d877aa5debb6a..98c95d2833eaa1c651006f802c997f632aed1227 100644 (file)
@@ -269,20 +269,13 @@ static int maps_open(struct inode *inode, struct file *file,
                     const struct seq_operations *ops)
 {
        struct proc_maps_private *priv;
-       int ret = -ENOMEM;
-
-       priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-       if (priv) {
-               priv->pid = proc_pid(inode);
-               ret = seq_open(file, ops);
-               if (!ret) {
-                       struct seq_file *m = file->private_data;
-                       m->private = priv;
-               } else {
-                       kfree(priv);
-               }
-       }
-       return ret;
+
+       priv = __seq_open_private(file, ops, sizeof(struct proc_maps_private));
+       if (!priv)
+               return -ENOMEM;
+
+       priv->pid = proc_pid(inode);
+       return 0;
 }
 
 static int pid_maps_open(struct inode *inode, struct file *file)