Commit 0b2c4e39 authored by Al Viro's avatar Al Viro
Browse files

coda: deal correctly with allocation failure from coda_cnode_makectl()



lookup should fail with ENOMEM, not silently make dentry negative.
Switched to saner calling conventions, while we are at it.

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 3e25eb9c
Loading
Loading
Loading
Loading
+9 −12
Original line number Original line Diff line number Diff line
@@ -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 */
/* 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;
	struct inode *inode = new_inode(sb);

	if (inode) {
	*inode = new_inode(sb);
		inode->i_ino = CTL_INO;
	if (*inode) {
		inode->i_op = &coda_ioctl_inode_operations;
		(*inode)->i_ino = CTL_INO;
		inode->i_fop = &coda_ioctl_operations;
		(*inode)->i_op = &coda_ioctl_inode_operations;
		inode->i_mode = 0444;
		(*inode)->i_fop = &coda_ioctl_operations;
		return inode;
		(*inode)->i_mode = 0444;
		error = 0;
	}
	}

	return ERR_PTR(-ENOMEM);
	return error;
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -51,7 +51,7 @@ struct coda_file_info {


int coda_cnode_make(struct inode **, struct CodaFid *, struct super_block *);
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);
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);
struct inode *coda_fid_to_inode(struct CodaFid *fid, struct super_block *sb);
void coda_replace_fid(struct inode *, struct CodaFid *, struct CodaFid *);
void coda_replace_fid(struct inode *, struct CodaFid *, struct CodaFid *);


+2 −2
Original line number Original line Diff line number Diff line
@@ -111,7 +111,7 @@ static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, struc


	/* control object, create inode on the fly */
	/* control object, create inode on the fly */
	if (coda_isroot(dir) && coda_iscontrol(name, length)) {
	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;
		type = CODA_NOCACHE;
		goto exit;
		goto exit;
	}
	}
@@ -125,7 +125,7 @@ static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, struc
		return ERR_PTR(error);
		return ERR_PTR(error);


exit:
exit:
	if (inode && (type & CODA_NOCACHE))
	if (inode && !IS_ERR(inode) && (type & CODA_NOCACHE))
		coda_flag_inode(inode, C_VATTR | C_PURGE);
		coda_flag_inode(inode, C_VATTR | C_PURGE);


	return d_splice_alias(inode, entry);
	return d_splice_alias(inode, entry);