Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 26770
b: refs/heads/master
c: 84efad1
h: refs/heads/master
v: v3
  • Loading branch information
Joel Becker authored and Mark Fasheh committed May 17, 2006
1 parent ee8e5b6 commit 651944d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: afae00ab45ea71d89086f924ebee6ca51c81e48e
refs/heads/master: 84efad1a53dd05969094f9a2562b4e6666571c00
37 changes: 26 additions & 11 deletions trunk/fs/configfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,13 +704,18 @@ static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
struct module *owner;
char *name;

if (dentry->d_parent == configfs_sb->s_root)
return -EPERM;
if (dentry->d_parent == configfs_sb->s_root) {
ret = -EPERM;
goto out;
}

sd = dentry->d_parent->d_fsdata;
if (!(sd->s_type & CONFIGFS_USET_DIR))
return -EPERM;
if (!(sd->s_type & CONFIGFS_USET_DIR)) {
ret = -EPERM;
goto out;
}

/* Get a working ref for the duration of this function */
parent_item = configfs_get_config_item(dentry->d_parent);
type = parent_item->ci_type;
subsys = to_config_group(parent_item)->cg_subsys;
Expand All @@ -719,15 +724,16 @@ static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
if (!type || !type->ct_group_ops ||
(!type->ct_group_ops->make_group &&
!type->ct_group_ops->make_item)) {
config_item_put(parent_item);
return -EPERM; /* What lack-of-mkdir returns */
ret = -EPERM; /* Lack-of-mkdir returns -EPERM */
goto out_put;
}

name = kmalloc(dentry->d_name.len + 1, GFP_KERNEL);
if (!name) {
config_item_put(parent_item);
return -ENOMEM;
ret = -ENOMEM;
goto out_put;
}

snprintf(name, dentry->d_name.len + 1, "%s", dentry->d_name.name);

down(&subsys->su_sem);
Expand All @@ -748,8 +754,8 @@ static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)

kfree(name);
if (!item) {
config_item_put(parent_item);
return -ENOMEM;
ret = -ENOMEM;
goto out_put;
}

ret = -EINVAL;
Expand All @@ -776,12 +782,19 @@ static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
client_drop_item(parent_item, item);
up(&subsys->su_sem);

config_item_put(parent_item);
module_put(owner);
}
}
}

out_put:
/*
* link_obj()/link_group() took a reference from child->parent.
* Drop our working ref
*/
config_item_put(parent_item);

out:
return ret;
}

Expand All @@ -801,6 +814,7 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry)
if (sd->s_type & CONFIGFS_USET_DEFAULT)
return -EPERM;

/* Get a working ref until we have the child */
parent_item = configfs_get_config_item(dentry->d_parent);
subsys = to_config_group(parent_item)->cg_subsys;
BUG_ON(!subsys);
Expand All @@ -817,6 +831,7 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry)
return ret;
}

/* Get a working ref for the duration of this function */
item = configfs_get_config_item(dentry);

/* Drop reference from above, item already holds one. */
Expand Down

0 comments on commit 651944d

Please sign in to comment.