]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
saner proc_get_inode() calling conventions
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 26 Jan 2013 01:11:22 +0000 (20:11 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Mar 2013 19:17:32 +0000 (12:17 -0700)
commit d3d009cb965eae7e002ea5badf603ea8f4c34915 upstream.

Make it drop the pde in *all* cases when no new reference to it is
put into an inode - both when an inode had already been set up
(as we were already doing) and when inode allocation has failed.
Makes for simpler logics in callers...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Dave Jones <davej@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/proc/generic.c
fs/proc/inode.c

index 76ddae83daa58e2b086dd286c847c47de71f1124..b796da2e674d9fbd6ce77483fda6c95512ce0649 100644 (file)
@@ -412,8 +412,7 @@ static const struct dentry_operations proc_dentry_operations =
 struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
                struct dentry *dentry)
 {
-       struct inode *inode = NULL;
-       int error = -ENOENT;
+       struct inode *inode;
 
        spin_lock(&proc_subdir_lock);
        for (de = de->subdir; de ; de = de->next) {
@@ -422,22 +421,16 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
                if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
                        pde_get(de);
                        spin_unlock(&proc_subdir_lock);
-                       error = -ENOMEM;
                        inode = proc_get_inode(dir->i_sb, de);
-                       goto out_unlock;
+                       if (!inode)
+                               return ERR_PTR(-ENOMEM);
+                       d_set_d_op(dentry, &proc_dentry_operations);
+                       d_add(dentry, inode);
+                       return NULL;
                }
        }
        spin_unlock(&proc_subdir_lock);
-out_unlock:
-
-       if (inode) {
-               d_set_d_op(dentry, &proc_dentry_operations);
-               d_add(dentry, inode);
-               return NULL;
-       }
-       if (de)
-               pde_put(de);
-       return ERR_PTR(error);
+       return ERR_PTR(-ENOENT);
 }
 
 struct dentry *proc_lookup(struct inode *dir, struct dentry *dentry,
index 439ae688650739f173499a635d578c99f104cebf..cec5245d1a0674ea94f91be6532ddcf2a3aec886 100644 (file)
@@ -445,12 +445,9 @@ static const struct file_operations proc_reg_file_ops_no_compat = {
 
 struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
 {
-       struct inode * inode;
+       struct inode *inode = iget_locked(sb, de->low_ino);
 
-       inode = iget_locked(sb, de->low_ino);
-       if (!inode)
-               return NULL;
-       if (inode->i_state & I_NEW) {
+       if (inode && (inode->i_state & I_NEW)) {
                inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
                PROC_I(inode)->pde = de;
 
@@ -482,7 +479,7 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
        } else
               pde_put(de);
        return inode;
-}                      
+}
 
 int proc_fill_super(struct super_block *s)
 {
@@ -499,6 +496,5 @@ int proc_fill_super(struct super_block *s)
                return 0;
 
        printk("proc_read_super: get root inode failed\n");
-       pde_put(&proc_root);
        return -ENOMEM;
 }