aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/filesystems/configfs/configfs.txt10
-rw-r--r--Documentation/filesystems/configfs/configfs_example.c14
-rw-r--r--drivers/net/netconsole.c10
-rw-r--r--fs/configfs/dir.c13
-rw-r--r--fs/dlm/config.c45
-rw-r--r--fs/ocfs2/cluster/heartbeat.c17
-rw-r--r--fs/ocfs2/cluster/nodemanager.c45
-rw-r--r--include/linux/configfs.h4
8 files changed, 64 insertions, 94 deletions
diff --git a/Documentation/filesystems/configfs/configfs.txt b/Documentation/filesystems/configfs/configfs.txt
index 15838d706ea2..44c97e6accb2 100644
--- a/Documentation/filesystems/configfs/configfs.txt
+++ b/Documentation/filesystems/configfs/configfs.txt
@@ -233,12 +233,10 @@ accomplished via the group operations specified on the group's
233config_item_type. 233config_item_type.
234 234
235 struct configfs_group_operations { 235 struct configfs_group_operations {
236 int (*make_item)(struct config_group *group, 236 struct config_item *(*make_item)(struct config_group *group,
237 const char *name, 237 const char *name);
238 struct config_item **new_item); 238 struct config_group *(*make_group)(struct config_group *group,
239 int (*make_group)(struct config_group *group, 239 const char *name);
240 const char *name,
241 struct config_group **new_group);
242 int (*commit_item)(struct config_item *item); 240 int (*commit_item)(struct config_item *item);
243 void (*disconnect_notify)(struct config_group *group, 241 void (*disconnect_notify)(struct config_group *group,
244 struct config_item *item); 242 struct config_item *item);
diff --git a/Documentation/filesystems/configfs/configfs_example.c b/Documentation/filesystems/configfs/configfs_example.c
index 0b422acd470c..25151fd5c2c6 100644
--- a/Documentation/filesystems/configfs/configfs_example.c
+++ b/Documentation/filesystems/configfs/configfs_example.c
@@ -273,13 +273,13 @@ static inline struct simple_children *to_simple_children(struct config_item *ite
273 return item ? container_of(to_config_group(item), struct simple_children, group) : NULL; 273 return item ? container_of(to_config_group(item), struct simple_children, group) : NULL;
274} 274}
275 275
276static int simple_children_make_item(struct config_group *group, const char *name, struct config_item **new_item) 276static struct config_item *simple_children_make_item(struct config_group *group, const char *name)
277{ 277{
278 struct simple_child *simple_child; 278 struct simple_child *simple_child;
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 -ENOMEM; 282 return NULL;
283 283
284 284
285 config_item_init_type_name(&simple_child->item, name, 285 config_item_init_type_name(&simple_child->item, name,
@@ -287,8 +287,7 @@ static int simple_children_make_item(struct config_group *group, const char *nam
287 287
288 simple_child->storeme = 0; 288 simple_child->storeme = 0;
289 289
290 *new_item = &simple_child->item; 290 return &simple_child->item;
291 return 0;
292} 291}
293 292
294static struct configfs_attribute simple_children_attr_description = { 293static struct configfs_attribute simple_children_attr_description = {
@@ -360,21 +359,20 @@ static struct configfs_subsystem simple_children_subsys = {
360 * children of its own. 359 * children of its own.
361 */ 360 */
362 361
363static int group_children_make_group(struct config_group *group, const char *name, struct config_group **new_group) 362static struct config_group *group_children_make_group(struct config_group *group, const char *name)
364{ 363{
365 struct simple_children *simple_children; 364 struct simple_children *simple_children;
366 365
367 simple_children = kzalloc(sizeof(struct simple_children), 366 simple_children = kzalloc(sizeof(struct simple_children),
368 GFP_KERNEL); 367 GFP_KERNEL);
369 if (!simple_children) 368 if (!simple_children)
370 return -ENOMEM; 369 return NULL;
371 370
372 371
373 config_group_init_type_name(&simple_children->group, name, 372 config_group_init_type_name(&simple_children->group, name,
374 &simple_children_type); 373 &simple_children_type);
375 374
376 *new_group = &simple_children->group; 375 return &simple_children->group;
377 return 0;
378} 376}
379 377
380static struct configfs_attribute group_children_attr_description = { 378static struct configfs_attribute group_children_attr_description = {
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 387a13395015..665341e43055 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -585,9 +585,8 @@ static struct config_item_type netconsole_target_type = {
585 * Group operations and type for netconsole_subsys. 585 * Group operations and type for netconsole_subsys.
586 */ 586 */
587 587
588static int make_netconsole_target(struct config_group *group, 588static struct config_item *make_netconsole_target(struct config_group *group,
589 const char *name, 589 const char *name)
590 struct config_item **new_item)
591{ 590{
592 unsigned long flags; 591 unsigned long flags;
593 struct netconsole_target *nt; 592 struct netconsole_target *nt;
@@ -599,7 +598,7 @@ static int make_netconsole_target(struct config_group *group,
599 nt = kzalloc(sizeof(*nt), GFP_KERNEL); 598 nt = kzalloc(sizeof(*nt), GFP_KERNEL);
600 if (!nt) { 599 if (!nt) {
601 printk(KERN_ERR "netconsole: failed to allocate memory\n"); 600 printk(KERN_ERR "netconsole: failed to allocate memory\n");
602 return -ENOMEM; 601 return NULL;
603 } 602 }
604 603
605 nt->np.name = "netconsole"; 604 nt->np.name = "netconsole";
@@ -616,8 +615,7 @@ static int make_netconsole_target(struct config_group *group,
616 list_add(&nt->list, &target_list); 615 list_add(&nt->list, &target_list);
617 spin_unlock_irqrestore(&target_list_lock, flags); 616 spin_unlock_irqrestore(&target_list_lock, flags);
618 617
619 *new_item = &nt->item; 618 return &nt->item;
620 return 0;
621} 619}
622 620
623static void drop_netconsole_target(struct config_group *group, 621static void drop_netconsole_target(struct config_group *group,
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 0e64312a084c..614e382a6049 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -1073,24 +1073,25 @@ static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
1073 group = NULL; 1073 group = NULL;
1074 item = NULL; 1074 item = NULL;
1075 if (type->ct_group_ops->make_group) { 1075 if (type->ct_group_ops->make_group) {
1076 ret = type->ct_group_ops->make_group(to_config_group(parent_item), name, &group); 1076 group = type->ct_group_ops->make_group(to_config_group(parent_item), name);
1077 if (!ret) { 1077 if (group) {
1078 link_group(to_config_group(parent_item), group); 1078 link_group(to_config_group(parent_item), group);
1079 item = &group->cg_item; 1079 item = &group->cg_item;
1080 } 1080 }
1081 } else { 1081 } else {
1082 ret = type->ct_group_ops->make_item(to_config_group(parent_item), name, &item); 1082 item = type->ct_group_ops->make_item(to_config_group(parent_item), name);
1083 if (!ret) 1083 if (item)
1084 link_obj(parent_item, item); 1084 link_obj(parent_item, item);
1085 } 1085 }
1086 mutex_unlock(&subsys->su_mutex); 1086 mutex_unlock(&subsys->su_mutex);
1087 1087
1088 kfree(name); 1088 kfree(name);
1089 if (ret) { 1089 if (!item) {
1090 /* 1090 /*
1091 * If ret != 0, then link_obj() was never called. 1091 * If item == NULL, then link_obj() was never called.
1092 * There are no extra references to clean up. 1092 * There are no extra references to clean up.
1093 */ 1093 */
1094 ret = -ENOMEM;
1094 goto out_put; 1095 goto out_put;
1095 } 1096 }
1096 1097
diff --git a/fs/dlm/config.c b/fs/dlm/config.c
index 492d8caaaf25..eac23bd288b2 100644
--- a/fs/dlm/config.c
+++ b/fs/dlm/config.c
@@ -41,20 +41,16 @@ struct comm;
41struct nodes; 41struct nodes;
42struct node; 42struct node;
43 43
44static int make_cluster(struct config_group *, const char *, 44static struct config_group *make_cluster(struct config_group *, const char *);
45 struct config_group **);
46static void drop_cluster(struct config_group *, struct config_item *); 45static void drop_cluster(struct config_group *, struct config_item *);
47static void release_cluster(struct config_item *); 46static void release_cluster(struct config_item *);
48static int make_space(struct config_group *, const char *, 47static struct config_group *make_space(struct config_group *, const char *);
49 struct config_group **);
50static void drop_space(struct config_group *, struct config_item *); 48static void drop_space(struct config_group *, struct config_item *);
51static void release_space(struct config_item *); 49static void release_space(struct config_item *);
52static int make_comm(struct config_group *, const char *, 50static struct config_item *make_comm(struct config_group *, const char *);
53 struct config_item **);
54static void drop_comm(struct config_group *, struct config_item *); 51static void drop_comm(struct config_group *, struct config_item *);
55static void release_comm(struct config_item *); 52static void release_comm(struct config_item *);
56static int make_node(struct config_group *, const char *, 53static struct config_item *make_node(struct config_group *, const char *);
57 struct config_item **);
58static void drop_node(struct config_group *, struct config_item *); 54static void drop_node(struct config_group *, struct config_item *);
59static void release_node(struct config_item *); 55static void release_node(struct config_item *);
60 56
@@ -396,8 +392,8 @@ static struct node *to_node(struct config_item *i)
396 return i ? container_of(i, struct node, item) : NULL; 392 return i ? container_of(i, struct node, item) : NULL;
397} 393}
398 394
399static int make_cluster(struct config_group *g, const char *name, 395static struct config_group *make_cluster(struct config_group *g,
400 struct config_group **new_g) 396 const char *name)
401{ 397{
402 struct cluster *cl = NULL; 398 struct cluster *cl = NULL;
403 struct spaces *sps = NULL; 399 struct spaces *sps = NULL;
@@ -435,15 +431,14 @@ static int make_cluster(struct config_group *g, const char *name,
435 431
436 space_list = &sps->ss_group; 432 space_list = &sps->ss_group;
437 comm_list = &cms->cs_group; 433 comm_list = &cms->cs_group;
438 *new_g = &cl->group; 434 return &cl->group;
439 return 0;
440 435
441 fail: 436 fail:
442 kfree(cl); 437 kfree(cl);
443 kfree(gps); 438 kfree(gps);
444 kfree(sps); 439 kfree(sps);
445 kfree(cms); 440 kfree(cms);
446 return -ENOMEM; 441 return NULL;
447} 442}
448 443
449static void drop_cluster(struct config_group *g, struct config_item *i) 444static void drop_cluster(struct config_group *g, struct config_item *i)
@@ -471,8 +466,7 @@ static void release_cluster(struct config_item *i)
471 kfree(cl); 466 kfree(cl);
472} 467}
473 468
474static int make_space(struct config_group *g, const char *name, 469static struct config_group *make_space(struct config_group *g, const char *name)
475 struct config_group **new_g)
476{ 470{
477 struct space *sp = NULL; 471 struct space *sp = NULL;
478 struct nodes *nds = NULL; 472 struct nodes *nds = NULL;
@@ -495,14 +489,13 @@ static int make_space(struct config_group *g, const char *name,
495 INIT_LIST_HEAD(&sp->members); 489 INIT_LIST_HEAD(&sp->members);
496 mutex_init(&sp->members_lock); 490 mutex_init(&sp->members_lock);
497 sp->members_count = 0; 491 sp->members_count = 0;
498 *new_g = &sp->group; 492 return &sp->group;
499 return 0;
500 493
501 fail: 494 fail:
502 kfree(sp); 495 kfree(sp);
503 kfree(gps); 496 kfree(gps);
504 kfree(nds); 497 kfree(nds);
505 return -ENOMEM; 498 return NULL;
506} 499}
507 500
508static void drop_space(struct config_group *g, struct config_item *i) 501static void drop_space(struct config_group *g, struct config_item *i)
@@ -529,21 +522,19 @@ static void release_space(struct config_item *i)
529 kfree(sp); 522 kfree(sp);
530} 523}
531 524
532static int make_comm(struct config_group *g, const char *name, 525static struct config_item *make_comm(struct config_group *g, const char *name)
533 struct config_item **new_i)
534{ 526{
535 struct comm *cm; 527 struct comm *cm;
536 528
537 cm = kzalloc(sizeof(struct comm), GFP_KERNEL); 529 cm = kzalloc(sizeof(struct comm), GFP_KERNEL);
538 if (!cm) 530 if (!cm)
539 return -ENOMEM; 531 return NULL;
540 532
541 config_item_init_type_name(&cm->item, name, &comm_type); 533 config_item_init_type_name(&cm->item, name, &comm_type);
542 cm->nodeid = -1; 534 cm->nodeid = -1;
543 cm->local = 0; 535 cm->local = 0;
544 cm->addr_count = 0; 536 cm->addr_count = 0;
545 *new_i = &cm->item; 537 return &cm->item;
546 return 0;
547} 538}
548 539
549static void drop_comm(struct config_group *g, struct config_item *i) 540static void drop_comm(struct config_group *g, struct config_item *i)
@@ -563,15 +554,14 @@ static void release_comm(struct config_item *i)
563 kfree(cm); 554 kfree(cm);
564} 555}
565 556
566static int make_node(struct config_group *g, const char *name, 557static struct config_item *make_node(struct config_group *g, const char *name)
567 struct config_item **new_i)
568{ 558{
569 struct space *sp = to_space(g->cg_item.ci_parent); 559 struct space *sp = to_space(g->cg_item.ci_parent);
570 struct node *nd; 560 struct node *nd;
571 561
572 nd = kzalloc(sizeof(struct node), GFP_KERNEL); 562 nd = kzalloc(sizeof(struct node), GFP_KERNEL);
573 if (!nd) 563 if (!nd)
574 return -ENOMEM; 564 return NULL;
575 565
576 config_item_init_type_name(&nd->item, name, &node_type); 566 config_item_init_type_name(&nd->item, name, &node_type);
577 nd->nodeid = -1; 567 nd->nodeid = -1;
@@ -583,8 +573,7 @@ static int make_node(struct config_group *g, const char *name,
583 sp->members_count++; 573 sp->members_count++;
584 mutex_unlock(&sp->members_lock); 574 mutex_unlock(&sp->members_lock);
585 575
586 *new_i = &nd->item; 576 return &nd->item;
587 return 0;
588} 577}
589 578
590static void drop_node(struct config_group *g, struct config_item *i) 579static void drop_node(struct config_group *g, struct config_item *i)
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 443d108211ab..f02ccb34604d 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1489,28 +1489,25 @@ static struct o2hb_heartbeat_group *to_o2hb_heartbeat_group(struct config_group
1489 : NULL; 1489 : NULL;
1490} 1490}
1491 1491
1492static int o2hb_heartbeat_group_make_item(struct config_group *group, 1492static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *group,
1493 const char *name, 1493 const char *name)
1494 struct config_item **new_item)
1495{ 1494{
1496 struct o2hb_region *reg = NULL; 1495 struct o2hb_region *reg = NULL;
1497 int ret = 0; 1496 struct config_item *ret = NULL;
1498 1497
1499 reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL); 1498 reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL);
1500 if (reg == NULL) { 1499 if (reg == NULL)
1501 ret = -ENOMEM; 1500 goto out; /* ENOMEM */
1502 goto out;
1503 }
1504 1501
1505 config_item_init_type_name(&reg->hr_item, name, &o2hb_region_type); 1502 config_item_init_type_name(&reg->hr_item, name, &o2hb_region_type);
1506 1503
1507 *new_item = &reg->hr_item; 1504 ret = &reg->hr_item;
1508 1505
1509 spin_lock(&o2hb_live_lock); 1506 spin_lock(&o2hb_live_lock);
1510 list_add_tail(&reg->hr_all_item, &o2hb_all_regions); 1507 list_add_tail(&reg->hr_all_item, &o2hb_all_regions);
1511 spin_unlock(&o2hb_live_lock); 1508 spin_unlock(&o2hb_live_lock);
1512out: 1509out:
1513 if (ret) 1510 if (ret == NULL)
1514 kfree(reg); 1511 kfree(reg);
1515 1512
1516 return ret; 1513 return ret;
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c
index b364b7052e46..cfdb08b484ed 100644
--- a/fs/ocfs2/cluster/nodemanager.c
+++ b/fs/ocfs2/cluster/nodemanager.c
@@ -644,32 +644,27 @@ out:
644 return ret; 644 return ret;
645} 645}
646 646
647static int o2nm_node_group_make_item(struct config_group *group, 647static struct config_item *o2nm_node_group_make_item(struct config_group *group,
648 const char *name, 648 const char *name)
649 struct config_item **new_item)
650{ 649{
651 struct o2nm_node *node = NULL; 650 struct o2nm_node *node = NULL;
652 int ret = 0; 651 struct config_item *ret = NULL;
653 652
654 if (strlen(name) > O2NM_MAX_NAME_LEN) { 653 if (strlen(name) > O2NM_MAX_NAME_LEN)
655 ret = -ENAMETOOLONG; 654 goto out; /* ENAMETOOLONG */
656 goto out;
657 }
658 655
659 node = kzalloc(sizeof(struct o2nm_node), GFP_KERNEL); 656 node = kzalloc(sizeof(struct o2nm_node), GFP_KERNEL);
660 if (node == NULL) { 657 if (node == NULL)
661 ret = -ENOMEM; 658 goto out; /* ENOMEM */
662 goto out;
663 }
664 659
665 strcpy(node->nd_name, name); /* use item.ci_namebuf instead? */ 660 strcpy(node->nd_name, name); /* use item.ci_namebuf instead? */
666 config_item_init_type_name(&node->nd_item, name, &o2nm_node_type); 661 config_item_init_type_name(&node->nd_item, name, &o2nm_node_type);
667 spin_lock_init(&node->nd_lock); 662 spin_lock_init(&node->nd_lock);
668 663
669 *new_item = &node->nd_item; 664 ret = &node->nd_item;
670 665
671out: 666out:
672 if (ret) 667 if (ret == NULL)
673 kfree(node); 668 kfree(node);
674 669
675 return ret; 670 return ret;
@@ -756,31 +751,25 @@ static struct o2nm_cluster_group *to_o2nm_cluster_group(struct config_group *gro
756} 751}
757#endif 752#endif
758 753
759static int o2nm_cluster_group_make_group(struct config_group *group, 754static struct config_group *o2nm_cluster_group_make_group(struct config_group *group,
760 const char *name, 755 const char *name)
761 struct config_group **new_group)
762{ 756{
763 struct o2nm_cluster *cluster = NULL; 757 struct o2nm_cluster *cluster = NULL;
764 struct o2nm_node_group *ns = NULL; 758 struct o2nm_node_group *ns = NULL;
765 struct config_group *o2hb_group = NULL; 759 struct config_group *o2hb_group = NULL, *ret = NULL;
766 void *defs = NULL; 760 void *defs = NULL;
767 int ret = 0;
768 761
769 /* this runs under the parent dir's i_mutex; there can be only 762 /* this runs under the parent dir's i_mutex; there can be only
770 * one caller in here at a time */ 763 * one caller in here at a time */
771 if (o2nm_single_cluster) { 764 if (o2nm_single_cluster)
772 ret = -ENOSPC; 765 goto out; /* ENOSPC */
773 goto out;
774 }
775 766
776 cluster = kzalloc(sizeof(struct o2nm_cluster), GFP_KERNEL); 767 cluster = kzalloc(sizeof(struct o2nm_cluster), GFP_KERNEL);
777 ns = kzalloc(sizeof(struct o2nm_node_group), GFP_KERNEL); 768 ns = kzalloc(sizeof(struct o2nm_node_group), GFP_KERNEL);
778 defs = kcalloc(3, sizeof(struct config_group *), GFP_KERNEL); 769 defs = kcalloc(3, sizeof(struct config_group *), GFP_KERNEL);
779 o2hb_group = o2hb_alloc_hb_set(); 770 o2hb_group = o2hb_alloc_hb_set();
780 if (cluster == NULL || ns == NULL || o2hb_group == NULL || defs == NULL) { 771 if (cluster == NULL || ns == NULL || o2hb_group == NULL || defs == NULL)
781 ret = -ENOMEM;
782 goto out; 772 goto out;
783 }
784 773
785 config_group_init_type_name(&cluster->cl_group, name, 774 config_group_init_type_name(&cluster->cl_group, name,
786 &o2nm_cluster_type); 775 &o2nm_cluster_type);
@@ -797,11 +786,11 @@ static int o2nm_cluster_group_make_group(struct config_group *group,
797 cluster->cl_idle_timeout_ms = O2NET_IDLE_TIMEOUT_MS_DEFAULT; 786 cluster->cl_idle_timeout_ms = O2NET_IDLE_TIMEOUT_MS_DEFAULT;
798 cluster->cl_keepalive_delay_ms = O2NET_KEEPALIVE_DELAY_MS_DEFAULT; 787 cluster->cl_keepalive_delay_ms = O2NET_KEEPALIVE_DELAY_MS_DEFAULT;
799 788
800 *new_group = &cluster->cl_group; 789 ret = &cluster->cl_group;
801 o2nm_single_cluster = cluster; 790 o2nm_single_cluster = cluster;
802 791
803out: 792out:
804 if (ret) { 793 if (ret == NULL) {
805 kfree(cluster); 794 kfree(cluster);
806 kfree(ns); 795 kfree(ns);
807 o2hb_free_hb_set(o2hb_group); 796 o2hb_free_hb_set(o2hb_group);
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index 0488f937634a..3ae65b1bf90f 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -165,8 +165,8 @@ struct configfs_item_operations {
165}; 165};
166 166
167struct configfs_group_operations { 167struct configfs_group_operations {
168 int (*make_item)(struct config_group *group, const char *name, struct config_item **new_item); 168 struct config_item *(*make_item)(struct config_group *group, const char *name);
169 int (*make_group)(struct config_group *group, const char *name, struct config_group **new_group); 169 struct config_group *(*make_group)(struct config_group *group, const char *name);
170 int (*commit_item)(struct config_item *item); 170 int (*commit_item)(struct config_item *item);
171 void (*disconnect_notify)(struct config_group *group, struct config_item *item); 171 void (*disconnect_notify)(struct config_group *group, struct config_item *item);
172 void (*drop_item)(struct config_group *group, struct config_item *item); 172 void (*drop_item)(struct config_group *group, struct config_item *item);