configfs: sanitize configfs_create()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
b7c177fcd2
commit
16d13b59b5
1 changed files with 27 additions and 28 deletions
|
@ -187,36 +187,35 @@ static void configfs_set_inode_lock_class(struct configfs_dirent *sd,
|
||||||
int configfs_create(struct dentry * dentry, umode_t mode, int (*init)(struct inode *))
|
int configfs_create(struct dentry * dentry, umode_t mode, int (*init)(struct inode *))
|
||||||
{
|
{
|
||||||
int error = 0;
|
int error = 0;
|
||||||
struct inode * inode = NULL;
|
struct inode *inode = NULL;
|
||||||
if (dentry) {
|
struct configfs_dirent *sd;
|
||||||
if (!dentry->d_inode) {
|
struct inode *p_inode;
|
||||||
struct configfs_dirent *sd = dentry->d_fsdata;
|
|
||||||
if ((inode = configfs_new_inode(mode, sd, dentry->d_sb))) {
|
|
||||||
if (dentry->d_parent && dentry->d_parent->d_inode) {
|
|
||||||
struct inode *p_inode = dentry->d_parent->d_inode;
|
|
||||||
p_inode->i_mtime = p_inode->i_ctime = CURRENT_TIME;
|
|
||||||
}
|
|
||||||
configfs_set_inode_lock_class(sd, inode);
|
|
||||||
goto Proceed;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
error = -ENOMEM;
|
|
||||||
} else
|
|
||||||
error = -EEXIST;
|
|
||||||
} else
|
|
||||||
error = -ENOENT;
|
|
||||||
goto Done;
|
|
||||||
|
|
||||||
Proceed:
|
if (!dentry)
|
||||||
if (init)
|
return -ENOENT;
|
||||||
|
|
||||||
|
if (dentry->d_inode)
|
||||||
|
return -EEXIST;
|
||||||
|
|
||||||
|
sd = dentry->d_fsdata;
|
||||||
|
inode = configfs_new_inode(mode, sd, dentry->d_sb);
|
||||||
|
if (!inode)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
p_inode = dentry->d_parent->d_inode;
|
||||||
|
p_inode->i_mtime = p_inode->i_ctime = CURRENT_TIME;
|
||||||
|
configfs_set_inode_lock_class(sd, inode);
|
||||||
|
|
||||||
|
if (init) {
|
||||||
error = init(inode);
|
error = init(inode);
|
||||||
if (!error) {
|
if (error) {
|
||||||
d_instantiate(dentry, inode);
|
iput(inode);
|
||||||
if (S_ISDIR(mode) || S_ISLNK(mode))
|
return error;
|
||||||
dget(dentry); /* pin link and directory dentries in core */
|
}
|
||||||
} else
|
}
|
||||||
iput(inode);
|
d_instantiate(dentry, inode);
|
||||||
Done:
|
if (S_ISDIR(mode) || S_ISLNK(mode))
|
||||||
|
dget(dentry); /* pin link and directory dentries in core */
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue