aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/filesystems/configfs/configfs_example.c4
-rw-r--r--drivers/net/netconsole.c2
-rw-r--r--fs/configfs/dir.c25
-rw-r--r--fs/dlm/config.c8
-rw-r--r--fs/ocfs2/cluster/heartbeat.c10
-rw-r--r--fs/ocfs2/cluster/nodemanager.c16
-rw-r--r--include/linux/configfs.h3
7 files changed, 31 insertions, 37 deletions
diff --git a/Documentation/filesystems/configfs/configfs_example.c b/Documentation/filesystems/configfs/configfs_example.c
index 25151fd5c2c6..039648791701 100644
--- a/Documentation/filesystems/configfs/configfs_example.c
+++ b/Documentation/filesystems/configfs/configfs_example.c
@@ -279,7 +279,7 @@ static struct config_item *simple_children_make_item(struct config_group *group,
279 279
280 simple_child = kzalloc(sizeof(struct simple_child), GFP_KERNEL); 280 simple_child = kzalloc(sizeof(struct simple_child), GFP_KERNEL);
281 if (!simple_child) 281 if (!simple_child)
282 return NULL; 282 return ERR_PTR(-ENOMEM);
283 283
284 284
285 config_item_init_type_name(&simple_child->item, name, 285 config_item_init_type_name(&simple_child->item, name,
@@ -366,7 +366,7 @@ static struct config_group *group_children_make_group(struct config_group *group
366 simple_children = kzalloc(sizeof(struct simple_children), 366 simple_children = kzalloc(sizeof(struct simple_children),
367 GFP_KERNEL); 367 GFP_KERNEL);
368 if (!simple_children) 368 if (!simple_children)
369 return NULL; 369 return ERR_PTR(-ENOMEM);
370 370
371 371
372 config_group_init_type_name(&simple_children->group, name, 372 config_group_init_type_name(&simple_children->group, name,
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 665341e43055..e13966bb5f77 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -598,7 +598,7 @@ static struct config_item *make_netconsole_target(struct config_group *group,
598 nt = kzalloc(sizeof(*nt), GFP_KERNEL); 598 nt = kzalloc(sizeof(*nt), GFP_KERNEL);
599 if (!nt) { 599 if (!nt) {
600 printk(KERN_ERR "netconsole: failed to allocate memory\n"); 600 printk(KERN_ERR "netconsole: failed to allocate memory\n");
601 return NULL; 601 return ERR_PTR(-ENOMEM);
602 } 602 }
603 603
604 nt->np.name = "netconsole"; 604 nt->np.name = "netconsole";
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
1028static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 1028static 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
diff --git a/fs/dlm/config.c b/fs/dlm/config.c
index eac23bd288b2..c4e7d721bd8d 100644
--- a/fs/dlm/config.c
+++ b/fs/dlm/config.c
@@ -438,7 +438,7 @@ static struct config_group *make_cluster(struct config_group *g,
438 kfree(gps); 438 kfree(gps);
439 kfree(sps); 439 kfree(sps);
440 kfree(cms); 440 kfree(cms);
441 return NULL; 441 return ERR_PTR(-ENOMEM);
442} 442}
443 443
444static void drop_cluster(struct config_group *g, struct config_item *i) 444static void drop_cluster(struct config_group *g, struct config_item *i)
@@ -495,7 +495,7 @@ static struct config_group *make_space(struct config_group *g, const char *name)
495 kfree(sp); 495 kfree(sp);
496 kfree(gps); 496 kfree(gps);
497 kfree(nds); 497 kfree(nds);
498 return NULL; 498 return ERR_PTR(-ENOMEM);
499} 499}
500 500
501static void drop_space(struct config_group *g, struct config_item *i) 501static void drop_space(struct config_group *g, struct config_item *i)
@@ -528,7 +528,7 @@ static struct config_item *make_comm(struct config_group *g, const char *name)
528 528
529 cm = kzalloc(sizeof(struct comm), GFP_KERNEL); 529 cm = kzalloc(sizeof(struct comm), GFP_KERNEL);
530 if (!cm) 530 if (!cm)
531 return NULL; 531 return ERR_PTR(-ENOMEM);
532 532
533 config_item_init_type_name(&cm->item, name, &comm_type); 533 config_item_init_type_name(&cm->item, name, &comm_type);
534 cm->nodeid = -1; 534 cm->nodeid = -1;
@@ -561,7 +561,7 @@ static struct config_item *make_node(struct config_group *g, const char *name)
561 561
562 nd = kzalloc(sizeof(struct node), GFP_KERNEL); 562 nd = kzalloc(sizeof(struct node), GFP_KERNEL);
563 if (!nd) 563 if (!nd)
564 return NULL; 564 return ERR_PTR(-ENOMEM);
565 565
566 config_item_init_type_name(&nd->item, name, &node_type); 566 config_item_init_type_name(&nd->item, name, &node_type);
567 nd->nodeid = -1; 567 nd->nodeid = -1;
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index f02ccb34604d..7dce1612553e 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1493,24 +1493,18 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g
1493 const char *name) 1493 const char *name)
1494{ 1494{
1495 struct o2hb_region *reg = NULL; 1495 struct o2hb_region *reg = NULL;
1496 struct config_item *ret = NULL;
1497 1496
1498 reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL); 1497 reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL);
1499 if (reg == NULL) 1498 if (reg == NULL)
1500 goto out; /* ENOMEM */ 1499 return ERR_PTR(-ENOMEM);
1501 1500
1502 config_item_init_type_name(&reg->hr_item, name, &o2hb_region_type); 1501 config_item_init_type_name(&reg->hr_item, name, &o2hb_region_type);
1503 1502
1504 ret = &reg->hr_item;
1505
1506 spin_lock(&o2hb_live_lock); 1503 spin_lock(&o2hb_live_lock);
1507 list_add_tail(&reg->hr_all_item, &o2hb_all_regions); 1504 list_add_tail(&reg->hr_all_item, &o2hb_all_regions);
1508 spin_unlock(&o2hb_live_lock); 1505 spin_unlock(&o2hb_live_lock);
1509out:
1510 if (ret == NULL)
1511 kfree(reg);
1512 1506
1513 return ret; 1507 return &reg->hr_item;
1514} 1508}
1515 1509
1516static void o2hb_heartbeat_group_drop_item(struct config_group *group, 1510static void o2hb_heartbeat_group_drop_item(struct config_group *group,
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c
index cfdb08b484ed..816a3f61330c 100644
--- a/fs/ocfs2/cluster/nodemanager.c
+++ b/fs/ocfs2/cluster/nodemanager.c
@@ -648,26 +648,19 @@ static struct config_item *o2nm_node_group_make_item(struct config_group *group,
648 const char *name) 648 const char *name)
649{ 649{
650 struct o2nm_node *node = NULL; 650 struct o2nm_node *node = NULL;
651 struct config_item *ret = NULL;
652 651
653 if (strlen(name) > O2NM_MAX_NAME_LEN) 652 if (strlen(name) > O2NM_MAX_NAME_LEN)
654 goto out; /* ENAMETOOLONG */ 653 return ERR_PTR(-ENAMETOOLONG);
655 654
656 node = kzalloc(sizeof(struct o2nm_node), GFP_KERNEL); 655 node = kzalloc(sizeof(struct o2nm_node), GFP_KERNEL);
657 if (node == NULL) 656 if (node == NULL)
658 goto out; /* ENOMEM */ 657 return ERR_PTR(-ENOMEM);
659 658
660 strcpy(node->nd_name, name); /* use item.ci_namebuf instead? */ 659 strcpy(node->nd_name, name); /* use item.ci_namebuf instead? */
661 config_item_init_type_name(&node->nd_item, name, &o2nm_node_type); 660 config_item_init_type_name(&node->nd_item, name, &o2nm_node_type);
662 spin_lock_init(&node->nd_lock); 661 spin_lock_init(&node->nd_lock);
663 662
664 ret = &node->nd_item; 663 return &node->nd_item;
665
666out:
667 if (ret == NULL)
668 kfree(node);
669
670 return ret;
671} 664}
672 665
673static void o2nm_node_group_drop_item(struct config_group *group, 666static void o2nm_node_group_drop_item(struct config_group *group,
@@ -762,7 +755,7 @@ static struct config_group *o2nm_cluster_group_make_group(struct config_group *g
762 /* this runs under the parent dir's i_mutex; there can be only 755 /* this runs under the parent dir's i_mutex; there can be only
763 * one caller in here at a time */ 756 * one caller in here at a time */
764 if (o2nm_single_cluster) 757 if (o2nm_single_cluster)
765 goto out; /* ENOSPC */ 758 return ERR_PTR(-ENOSPC);
766 759
767 cluster = kzalloc(sizeof(struct o2nm_cluster), GFP_KERNEL); 760 cluster = kzalloc(sizeof(struct o2nm_cluster), GFP_KERNEL);
768 ns = kzalloc(sizeof(struct o2nm_node_group), GFP_KERNEL); 761 ns = kzalloc(sizeof(struct o2nm_node_group), GFP_KERNEL);
@@ -795,6 +788,7 @@ out:
795 kfree(ns); 788 kfree(ns);
796 o2hb_free_hb_set(o2hb_group); 789 o2hb_free_hb_set(o2hb_group);
797 kfree(defs); 790 kfree(defs);
791 ret = ERR_PTR(-ENOMEM);
798 } 792 }
799 793
800 return ret; 794 return ret;
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index 3ae65b1bf90f..d62c19ff041c 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -148,7 +148,8 @@ struct configfs_attribute {
148 * items. If the item is a group, it may support mkdir(2). 148 * items. If the item is a group, it may support mkdir(2).
149 * Groups supply one of make_group() and make_item(). If the 149 * Groups supply one of make_group() and make_item(). If the
150 * group supports make_group(), one can create group children. If it 150 * group supports make_group(), one can create group children. If it
151 * supports make_item(), one can create config_item children. If it has 151 * supports make_item(), one can create config_item children. make_group()
152 * and make_item() return ERR_PTR() on errors. If it has
152 * default_groups on group->default_groups, it has automatically created 153 * default_groups on group->default_groups, it has automatically created
153 * group children. default_groups may coexist alongsize make_group() or 154 * group children. default_groups may coexist alongsize make_group() or
154 * make_item(), but if the group wishes to have only default_groups 155 * make_item(), but if the group wishes to have only default_groups