fs/proc/thread_self.c: code cleanup for proc_setup_thread_self()
authorChengguang Xu <cgxu519@gmx.com>
Tue, 5 Mar 2019 23:50:25 +0000 (15:50 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 6 Mar 2019 05:07:21 +0000 (21:07 -0800)
Remove unnecessary ERR_PTR()/PTR_ERR() cast in proc_setup_thread_self().

Link: http://lkml.kernel.org/r/20190124030150.8472-2-cgxu519@gmx.com
Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/proc/thread_self.c

index b905010..f61ae53 100644 (file)
@@ -38,6 +38,7 @@ int proc_setup_thread_self(struct super_block *s)
        struct inode *root_inode = d_inode(s->s_root);
        struct pid_namespace *ns = proc_pid_ns(root_inode);
        struct dentry *thread_self;
+       int ret = -ENOMEM;
 
        inode_lock(root_inode);
        thread_self = d_alloc_name(s->s_root, "thread-self");
@@ -51,20 +52,19 @@ int proc_setup_thread_self(struct super_block *s)
                        inode->i_gid = GLOBAL_ROOT_GID;
                        inode->i_op = &proc_thread_self_inode_operations;
                        d_add(thread_self, inode);
+                       ret = 0;
                } else {
                        dput(thread_self);
-                       thread_self = ERR_PTR(-ENOMEM);
                }
-       } else {
-               thread_self = ERR_PTR(-ENOMEM);
        }
        inode_unlock(root_inode);
-       if (IS_ERR(thread_self)) {
+
+       if (ret)
                pr_err("proc_fill_super: can't allocate /proc/thread_self\n");
-               return PTR_ERR(thread_self);
-       }
-       ns->proc_thread_self = thread_self;
-       return 0;
+       else
+               ns->proc_thread_self = thread_self;
+
+       return ret;
 }
 
 void __init proc_thread_self_init(void)