summaryrefslogtreecommitdiffstats
path: root/net/tipc/bcast.c
diff options
context:
space:
mode:
authorAllan Stephens <allan.stephens@windriver.com>2011-10-24 10:29:26 -0400
committerPaul Gortmaker <paul.gortmaker@windriver.com>2011-12-27 11:33:47 -0500
commitc47e9b918844ab7bb139eada7b085c576ddf0afb (patch)
tree492e8ac4c1191b1c7be865efacc7833ebcb6fff9 /net/tipc/bcast.c
parent945af1c39df00a1e5873e38145432ba752ec49a0 (diff)
downloadlinux-c47e9b918844ab7bb139eada7b085c576ddf0afb.tar.gz
linux-c47e9b918844ab7bb139eada7b085c576ddf0afb.tar.bz2
linux-c47e9b918844ab7bb139eada7b085c576ddf0afb.zip
tipc: Eliminate dynamic allocation of broadcast link data structures
Creates global variables to hold the broadcast link's pseudo-bearer and pseudo-link structures, rather than allocating them dynamically. There is only a single instance of each structure, and changing over to static allocation allows elimination of code to handle the cases where dynamic allocation was unsuccessful. The memset in the teardown code may look like they aren't used, but the same teardown code is run when there is a non-fatal error at init-time, so that stale data isn't present when the user fixes the cause of the soft error. Signed-off-by: Allan Stephens <allan.stephens@windriver.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc/bcast.c')
-rw-r--r--net/tipc/bcast.c37
1 files changed, 11 insertions, 26 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 28908f54459e..738cb642d31b 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -98,10 +98,13 @@ struct bclink {
struct tipc_node *retransmit_to;
};
+static struct bcbearer bcast_bearer;
+static struct bclink bcast_link;
+
+static struct bcbearer *bcbearer = &bcast_bearer;
+static struct bclink *bclink = &bcast_link;
+static struct link *bcl = &bcast_link.link;
-static struct bcbearer *bcbearer;
-static struct bclink *bclink;
-static struct link *bcl;
static DEFINE_SPINLOCK(bc_lock);
/* broadcast-capable node map */
@@ -752,25 +755,13 @@ int tipc_bclink_set_queue_limits(u32 limit)
return 0;
}
-int tipc_bclink_init(void)
+void tipc_bclink_init(void)
{
- bcbearer = kzalloc(sizeof(*bcbearer), GFP_ATOMIC);
- bclink = kzalloc(sizeof(*bclink), GFP_ATOMIC);
- if (!bcbearer || !bclink) {
- warn("Broadcast link creation failed, no memory\n");
- kfree(bcbearer);
- bcbearer = NULL;
- kfree(bclink);
- bclink = NULL;
- return -ENOMEM;
- }
-
INIT_LIST_HEAD(&bcbearer->bearer.cong_links);
bcbearer->bearer.media = &bcbearer->media;
bcbearer->media.send_msg = tipc_bcbearer_send;
sprintf(bcbearer->media.name, "tipc-broadcast");
- bcl = &bclink->link;
INIT_LIST_HEAD(&bcl->waiting_ports);
bcl->next_out_no = 1;
spin_lock_init(&bclink->node.lock);
@@ -780,22 +771,16 @@ int tipc_bclink_init(void)
bcl->b_ptr = &bcbearer->bearer;
bcl->state = WORKING_WORKING;
strlcpy(bcl->name, tipc_bclink_name, TIPC_MAX_LINK_NAME);
-
- return 0;
}
void tipc_bclink_stop(void)
{
spin_lock_bh(&bc_lock);
- if (bcbearer) {
- tipc_link_stop(bcl);
- bcl = NULL;
- kfree(bclink);
- bclink = NULL;
- kfree(bcbearer);
- bcbearer = NULL;
- }
+ tipc_link_stop(bcl);
spin_unlock_bh(&bc_lock);
+
+ memset(bclink, 0, sizeof(*bclink));
+ memset(bcbearer, 0, sizeof(*bcbearer));
}