diff options
Diffstat (limited to 'fs/configfs')
-rw-r--r-- | fs/configfs/dir.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index 614e382a6049..179589be063a 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c | |||
@@ -1027,9 +1027,10 @@ EXPORT_SYMBOL(configfs_undepend_item); | |||
1027 | 1027 | ||
1028 | static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | 1028 | static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) |
1029 | { | 1029 | { |
1030 | int ret, module_got = 0; | 1030 | int ret = 0; |
1031 | struct config_group *group; | 1031 | int module_got = 0; |
1032 | struct config_item *item; | 1032 | struct config_group *group = NULL; |
1033 | struct config_item *item = NULL; | ||
1033 | struct config_item *parent_item; | 1034 | struct config_item *parent_item; |
1034 | struct configfs_subsystem *subsys; | 1035 | struct configfs_subsystem *subsys; |
1035 | struct configfs_dirent *sd; | 1036 | struct configfs_dirent *sd; |
@@ -1070,28 +1071,32 @@ static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
1070 | snprintf(name, dentry->d_name.len + 1, "%s", dentry->d_name.name); | 1071 | snprintf(name, dentry->d_name.len + 1, "%s", dentry->d_name.name); |
1071 | 1072 | ||
1072 | mutex_lock(&subsys->su_mutex); | 1073 | mutex_lock(&subsys->su_mutex); |
1073 | group = NULL; | ||
1074 | item = NULL; | ||
1075 | if (type->ct_group_ops->make_group) { | 1074 | if (type->ct_group_ops->make_group) { |
1076 | group = type->ct_group_ops->make_group(to_config_group(parent_item), name); | 1075 | group = type->ct_group_ops->make_group(to_config_group(parent_item), name); |
1077 | if (group) { | 1076 | if (!group) |
1077 | group = ERR_PTR(-ENOMEM); | ||
1078 | if (!IS_ERR(group)) { | ||
1078 | link_group(to_config_group(parent_item), group); | 1079 | link_group(to_config_group(parent_item), group); |
1079 | item = &group->cg_item; | 1080 | item = &group->cg_item; |
1080 | } | 1081 | } else |
1082 | ret = PTR_ERR(group); | ||
1081 | } else { | 1083 | } else { |
1082 | item = type->ct_group_ops->make_item(to_config_group(parent_item), name); | 1084 | item = type->ct_group_ops->make_item(to_config_group(parent_item), name); |
1083 | if (item) | 1085 | if (!item) |
1086 | item = ERR_PTR(-ENOMEM); | ||
1087 | if (!IS_ERR(item)) | ||
1084 | link_obj(parent_item, item); | 1088 | link_obj(parent_item, item); |
1089 | else | ||
1090 | ret = PTR_ERR(item); | ||
1085 | } | 1091 | } |
1086 | mutex_unlock(&subsys->su_mutex); | 1092 | mutex_unlock(&subsys->su_mutex); |
1087 | 1093 | ||
1088 | kfree(name); | 1094 | kfree(name); |
1089 | if (!item) { | 1095 | if (ret) { |
1090 | /* | 1096 | /* |
1091 | * If item == NULL, then link_obj() was never called. | 1097 | * If item == NULL, then link_obj() was never called. |
1092 | * There are no extra references to clean up. | 1098 | * There are no extra references to clean up. |
1093 | */ | 1099 | */ |
1094 | ret = -ENOMEM; | ||
1095 | goto out_put; | 1100 | goto out_put; |
1096 | } | 1101 | } |
1097 | 1102 | ||