]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
coda: deal correctly with allocation failure from coda_cnode_makectl()
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 10 Jan 2012 15:46:03 +0000 (10:46 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 10 Jan 2012 16:13:13 +0000 (11:13 -0500)
lookup should fail with ENOMEM, not silently make dentry negative.
Switched to saner calling conventions, while we are at it.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/coda/cnode.c
fs/coda/coda_fs_i.h
fs/coda/dir.c

index 6475877b07632cda1af59664e629aa5ab92d958b..8af67c9c47dd49ad0bfb326074663f68210a3cd5 100644 (file)
@@ -156,19 +156,16 @@ struct inode *coda_fid_to_inode(struct CodaFid *fid, struct super_block *sb)
 }
 
 /* the CONTROL inode is made without asking attributes from Venus */
-int coda_cnode_makectl(struct inode **inode, struct super_block *sb)
+struct inode *coda_cnode_makectl(struct super_block *sb)
 {
-       int error = -ENOMEM;
-
-       *inode = new_inode(sb);
-       if (*inode) {
-               (*inode)->i_ino = CTL_INO;
-               (*inode)->i_op = &coda_ioctl_inode_operations;
-               (*inode)->i_fop = &coda_ioctl_operations;
-               (*inode)->i_mode = 0444;
-               error = 0;
+       struct inode *inode = new_inode(sb);
+       if (inode) {
+               inode->i_ino = CTL_INO;
+               inode->i_op = &coda_ioctl_inode_operations;
+               inode->i_fop = &coda_ioctl_operations;
+               inode->i_mode = 0444;
+               return inode;
        }
-
-       return error;
+       return ERR_PTR(-ENOMEM);
 }
 
index e35071b1de0e26a3d8f5e1ee27c1da3d3667a4ad..1c17446f1afec93b684f3bb796f600ef5036f855 100644 (file)
@@ -51,7 +51,7 @@ struct coda_file_info {
 
 int coda_cnode_make(struct inode **, struct CodaFid *, struct super_block *);
 struct inode *coda_iget(struct super_block *sb, struct CodaFid *fid, struct coda_vattr *attr);
-int coda_cnode_makectl(struct inode **inode, struct super_block *sb);
+struct inode *coda_cnode_makectl(struct super_block *sb);
 struct inode *coda_fid_to_inode(struct CodaFid *fid, struct super_block *sb);
 void coda_replace_fid(struct inode *, struct CodaFid *, struct CodaFid *);
 
index 83d2fd8ec24b2cac427be38610f36ea076a71eac..df0f9c1b01d3ae87d1bdda444588073d395ead99 100644 (file)
@@ -111,7 +111,7 @@ static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, struc
 
        /* control object, create inode on the fly */
        if (coda_isroot(dir) && coda_iscontrol(name, length)) {
-               error = coda_cnode_makectl(&inode, dir->i_sb);
+               inode = coda_cnode_makectl(dir->i_sb);
                type = CODA_NOCACHE;
                goto exit;
        }
@@ -125,7 +125,7 @@ static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, struc
                return ERR_PTR(error);
 
 exit:
-       if (inode && (type & CODA_NOCACHE))
+       if (inode && !IS_ERR(inode) && (type & CODA_NOCACHE))
                coda_flag_inode(inode, C_VATTR | C_PURGE);
 
        return d_splice_alias(inode, entry);